summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-05-19 00:41:31 -0700
committerGitHub <noreply@github.com>2020-05-19 09:41:31 +0200
commite909486e5cde5a4a77cd6f21b42fc9ab38ec2ae6 (patch)
tree7367a3774091f156d91e46cd4c292441ab3da46e
parent27741d6a5c9ec87a6938b2928ae54b22bc93d9be (diff)
downloadNim-e909486e5cde5a4a77cd6f21b42fc9ab38ec2ae6.tar.gz
trunner was not actually being tested in non-CTFFI mode; minor testament cleanups (#14377)
* use check
* trunner now works with cpp
* cleanup: move compiler/unittest_light => stdtest/unittest_light
* fix tests/readme.md
* remove deadcode references to rodfiles
* fix for windows
-rw-r--r--compiler/rodimpl.nim2
-rw-r--r--koch.nim2
-rw-r--r--lib/system/io.nim2
-rw-r--r--testament/categories.nim5
-rw-r--r--testament/lib/stdtest/unittest_light.nim (renamed from compiler/unittest_light.nim)0
-rw-r--r--tests/compiler/tasciitables.nim2
-rw-r--r--tests/compiler/tunittest_light.nim2
-rw-r--r--tests/misc/mbackend.nim1
-rw-r--r--tests/misc/msizeof5.nim2
-rw-r--r--tests/misc/tparseopt.nim2
-rw-r--r--tests/misc/trunner.nim (renamed from tests/trunner.nim)26
-rw-r--r--tests/readme.md13
-rw-r--r--tests/stdlib/tosproc.nim3
-rw-r--r--tests/stdlib/tstackframes.nim2
14 files changed, 30 insertions, 34 deletions
diff --git a/compiler/rodimpl.nim b/compiler/rodimpl.nim
index 8ee7ae564..417241930 100644
--- a/compiler/rodimpl.nim
+++ b/compiler/rodimpl.nim
@@ -916,6 +916,8 @@ proc loadNode*(g: ModuleGraph; module: PSym): PNode =
   replay(g, module, result)
 
 proc setupModuleCache*(g: ModuleGraph) =
+  ## historical note: there used to be a `rodfiles` dir with special tests
+  ## for incremental compilation via symbol files. This was likely replaced by ic.
   if g.config.symbolFiles == disabledSf: return
   g.recordStmt = recordStmt
   let dbfile = getNimcacheDir(g.config) / RelativeFile"rodfiles.db"
diff --git a/koch.nim b/koch.nim
index 3ec40534b..0391c3c4a 100644
--- a/koch.nim
+++ b/koch.nim
@@ -554,7 +554,7 @@ proc runCI(cmd: string) =
         # no need to bootstrap with koch boot (would be slower)
         let backend = if doUseCpp(): "cpp" else: "c"
         execFold("build with -d:nimHasLibFFI", "nim $1 -d:release -d:nimHasLibFFI -o:$2 compiler/nim.nim" % [backend, nimFFI])
-        execFold("test with -d:nimHasLibFFI", "$1 $2 -r testament/testament --nim:$1 r tests/trunner.nim" % [nimFFI, backend])
+        execFold("test with -d:nimHasLibFFI", "$1 $2 -r testament/testament --nim:$1 r tests/misc/trunner.nim -d:nimTrunnerFfi" % [nimFFI, backend])
 
     execFold("Run nimdoc tests", "nim c -r nimdoc/tester")
     execFold("Run nimpretty tests", "nim c -r nimpretty/tester.nim")
diff --git a/lib/system/io.nim b/lib/system/io.nim
index ab415f40c..84bebba28 100644
--- a/lib/system/io.nim
+++ b/lib/system/io.nim
@@ -733,7 +733,7 @@ when declared(stdout):
         releaseSys echoLock
 
 
-when defined(windows) and not defined(nimscript):
+when defined(windows) and not defined(nimscript) and not defined(js):
   # work-around C's sucking abstraction:
   # BUGFIX: stdin and stdout should be binary files!
   proc c_setmode(handle, mode: cint) {.
diff --git a/testament/categories.nim b/testament/categories.nim
index d60b89e33..114949ce8 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -32,7 +32,6 @@ const
     "nimble-packages-1",
     "nimble-packages-2",
     "niminaction",
-    "rodfiles",
     "threads",
     "untestable",
     "stdlib",
@@ -671,10 +670,6 @@ proc processCategory(r: var TResults, cat: Category,
                      options, testsDir: string,
                      runJoinableTests: bool) =
   case cat.string.normalize
-  of "rodfiles":
-    when false:
-      compileRodFiles(r, cat, options)
-      runRodFiles(r, cat, options)
   of "ic":
     when false:
       icTests(r, testsDir, cat, options)
diff --git a/compiler/unittest_light.nim b/testament/lib/stdtest/unittest_light.nim
index d9842b399..d9842b399 100644
--- a/compiler/unittest_light.nim
+++ b/testament/lib/stdtest/unittest_light.nim
diff --git a/tests/compiler/tasciitables.nim b/tests/compiler/tasciitables.nim
index 0a5ee0f05..80d648508 100644
--- a/tests/compiler/tasciitables.nim
+++ b/tests/compiler/tasciitables.nim
@@ -1,4 +1,4 @@
-import compiler/unittest_light
+import stdtest/unittest_light
 import compiler/asciitables
 
 import strformat
diff --git a/tests/compiler/tunittest_light.nim b/tests/compiler/tunittest_light.nim
index 5cad6997f..2951cc664 100644
--- a/tests/compiler/tunittest_light.nim
+++ b/tests/compiler/tunittest_light.nim
@@ -1,4 +1,4 @@
-import compiler/unittest_light
+import stdtest/unittest_light
 
 proc testAssertEquals() =
   assertEquals("foo", "foo")
diff --git a/tests/misc/mbackend.nim b/tests/misc/mbackend.nim
index e38eb2d3e..b6578a212 100644
--- a/tests/misc/mbackend.nim
+++ b/tests/misc/mbackend.nim
@@ -4,7 +4,6 @@ fixed would not trigger in that case.
 ]#
 
 import std/compilesettings
-import std/unittest
 
 static:
   ## bugfix 1: this used to CT error with: Error: unhandled exception: mimportcpp.nim(6, 18) `defined(cpp)`
diff --git a/tests/misc/msizeof5.nim b/tests/misc/msizeof5.nim
index c833d1e43..63573a705 100644
--- a/tests/misc/msizeof5.nim
+++ b/tests/misc/msizeof5.nim
@@ -116,7 +116,7 @@ when defined caseBad:
     ensureCgen Foo5
 
   block:
-    type Foo6{.importc, completeStruct.} = object
+    type Foo6{.importc:"struct Foo6", completeStruct.} = object
       a1: cint
       # a2: bool # missing this should trigger assert fail
       a3: cfloat
diff --git a/tests/misc/tparseopt.nim b/tests/misc/tparseopt.nim
index 25ce77816..a3dfcbb26 100644
--- a/tests/misc/tparseopt.nim
+++ b/tests/misc/tparseopt.nim
@@ -71,7 +71,7 @@ else:
 
   import osproc, os, strutils
   from stdtest/specialpaths import buildDir
-  import "../.." / compiler/unittest_light
+  import stdtest/unittest_light
 
   block: # fix #9951
     template runTest(parseoptCustom) =
diff --git a/tests/trunner.nim b/tests/misc/trunner.nim
index e89606bf7..bfe331c9c 100644
--- a/tests/trunner.nim
+++ b/tests/misc/trunner.nim
@@ -5,6 +5,7 @@ discard """
 
 ## tests that don't quite fit the mold and are easier to handle via `execCmdEx`
 ## A few others could be added to here to simplify code.
+## Note: this test is a bit slow but tests a lot of things; please don't disable.
 
 import std/[strformat,os,osproc,unittest]
 
@@ -15,7 +16,7 @@ const mode =
   elif defined(cpp): "cpp"
   else: static: doAssert false
 
-const testsDir = currentSourcePath().parentDir
+const testsDir = currentSourcePath.parentDir.parentDir
 const buildDir = testsDir.parentDir / "build"
 const nimcache = buildDir / "nimcacheTrunner"
   # `querySetting(nimcacheDir)` would also be possible, but we thus
@@ -28,7 +29,7 @@ proc runCmd(file, options = ""): auto =
   result = execCmdEx(cmd)
   when false:  echo result[0] & "\n" & result[1] # for debugging
 
-when defined(nimHasLibFFIEnabled):
+when defined(nimTrunnerFfi):
   block: # mevalffi
     when defined(openbsd):
       #[
@@ -65,7 +66,7 @@ else: # don't run twice the same test
   block: # mstatic_assert
     let (output, exitCode) = runCmd("ccgbugs/mstatic_assert.nim", "-d:caseBad")
     check2 "sizeof(bool) == 2"
-    doAssert exitCode != 0
+    check exitCode != 0
 
   block: # ABI checks
     let file = "misc/msizeof5.nim"
@@ -82,12 +83,11 @@ else: # don't run twice the same test
       check2 "sizeof(Foo5) == 16"
       check2 "sizeof(Foo5) == 3"
       check2 "sizeof(struct Foo6) == "
-      doAssert exitCode != 0
+      check exitCode != 0
 
   import streams
   block: # stdin input
-    let nimcmd = fmt"{nim} r --hints:off - -firstparam '-second param'"
-    let inputcmd = "import os; echo commandLineParams()"
+    let nimcmd = fmt"""{nim} r --hints:off - -firstparam "-second param" """
     let expected = """@["-firstparam", "-second param"]"""
     block:
       let p = startProcess(nimcmd, options = {poEvalCommand})
@@ -98,23 +98,27 @@ else: # don't run twice the same test
       doAssert p.waitForExit == 0
       doAssert error.len == 0, $error
       output.stripLineEnd
-      doAssert output == expected
+      check output == expected
       p.errorStream.close
       p.outputStream.close
 
     block:
-      when defined(posix):
-        let cmd = fmt"echo 'import os; echo commandLineParams()' | {nimcmd}"
+      when defined posix:
+        # xxx on windows, `poEvalCommand` should imply `/cmd`, (which should
+        # make this work), but currently doesn't
+        let cmd = fmt"""echo "import os; echo commandLineParams()" | {nimcmd}"""
         var (output, exitCode) = execCmdEx(cmd)
         output.stripLineEnd
-        doAssert output == expected
+        check output == expected
+        doAssert exitCode == 0
 
   block: # nim doc --backend:$backend --doccmd:$cmd
     # test for https://github.com/nim-lang/Nim/issues/13129
     # test for https://github.com/nim-lang/Nim/issues/13891
     let file = testsDir / "nimdoc/m13129.nim"
     for backend in fmt"{mode} js".split:
-      let cmd = fmt"{nim} doc -b:{backend} --nimcache:{nimcache} -d:m13129Foo1 --doccmd:'-d:m13129Foo2 --hints:off' --usenimcache --hints:off {file}"
+      # pending #14343 this fails on windows: --doccmd:"-d:m13129Foo2 --hints:off"
+      let cmd = fmt"""{nim} doc -b:{backend} --nimcache:{nimcache} -d:m13129Foo1 "--doccmd:-d:m13129Foo2 --hints:off" --usenimcache --hints:off {file}"""
       check execCmdEx(cmd) == (&"ok1:{backend}\nok2: backend: {backend}\n", 0)
     # checks that --usenimcache works with `nim doc`
     check fileExists(nimcache / "m13129.html")
diff --git a/tests/readme.md b/tests/readme.md
index b9b8abd39..234ee4efe 100644
--- a/tests/readme.md
+++ b/tests/readme.md
@@ -2,9 +2,8 @@ This directory contains the test cases.
 
 Each test must have a filename of the form: ``t*.nim``
 
-**Note:** Tests are only compiled by default. In order to get the tester to
-execute the compiled binary, you need to specify a spec with an ``action`` key
-(see below for details).
+**Note:** Testament is only aware of tests under a directory (eg `tests/foo/`) and will ignore
+top-level tests like `tests/tbar.nim`.
 
 # Specs
 
@@ -16,7 +15,7 @@ Each test can contain a spec in a ``discard """ ... """`` block.
 
 Specifies what action this test should take.
 
-**Default: compile**
+**Default: run**
 
 Options:
 
@@ -50,10 +49,8 @@ discard """
 # Categories
 
 Each folder under this directory represents a test category, which can be
-tested by running `koch tests cat <category>`.
-
-The folder ``rodfiles`` contains special tests that test incremental
-compilation via symbol files.
+tested by running `koch tests pcat <category>` (or `cat` to avoid parallel
+testing, which is slower).
 
 The folder ``dll`` contains simple DLL tests.
 
diff --git a/tests/stdlib/tosproc.nim b/tests/stdlib/tosproc.nim
index 36afd6a23..b5328c9eb 100644
--- a/tests/stdlib/tosproc.nim
+++ b/tests/stdlib/tosproc.nim
@@ -1,7 +1,6 @@
 # test the osproc module
 
-import stdtest/specialpaths
-import "$nim" / compiler/unittest_light
+import stdtest/[specialpaths, unittest_light]
 
 when defined(case_testfile): # compiled test file for child process
   from posix import exitnow
diff --git a/tests/stdlib/tstackframes.nim b/tests/stdlib/tstackframes.nim
index be66eb836..618ff7b92 100644
--- a/tests/stdlib/tstackframes.nim
+++ b/tests/stdlib/tstackframes.nim
@@ -1,5 +1,5 @@
 import std/[strformat,os,osproc]
-import "$nim/compiler/unittest_light" # works even if moved by megatest
+import stdtest/unittest_light
 
 proc main(opt: string, expected: string) =
   const nim = getCurrentCompilerExe()