diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/compiler/tasciitables.nim | 2 | ||||
-rw-r--r-- | tests/compiler/tunittest_light.nim | 2 | ||||
-rw-r--r-- | tests/misc/mbackend.nim | 1 | ||||
-rw-r--r-- | tests/misc/msizeof5.nim | 2 | ||||
-rw-r--r-- | tests/misc/tparseopt.nim | 2 | ||||
-rw-r--r-- | tests/misc/trunner.nim (renamed from tests/trunner.nim) | 26 | ||||
-rw-r--r-- | tests/readme.md | 13 | ||||
-rw-r--r-- | tests/stdlib/tosproc.nim | 3 | ||||
-rw-r--r-- | tests/stdlib/tstackframes.nim | 2 |
9 files changed, 26 insertions, 27 deletions
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() |