diff options
-rw-r--r-- | testament/categories.nim | 33 | ||||
-rw-r--r-- | tests/stdlib/tcgi.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/tfdleak.nim | 1 | ||||
-rw-r--r-- | tests/stdlib/tfdleak_multiple.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/tmarshal.nim | 5 | ||||
-rw-r--r-- | tests/stdlib/tnetbind.nim | 10 | ||||
-rw-r--r-- | tests/stdlib/tosproc.nim | 9 | ||||
-rw-r--r-- | tests/stdlib/trst.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/tstrutil.nim | 10 |
9 files changed, 64 insertions, 20 deletions
diff --git a/testament/categories.nim b/testament/categories.nim index 88f168608..4e83fa1a9 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -35,7 +35,6 @@ const "niminaction", "threads", "untestable", - "stdlib", "testdata", "nimcache", "coroutines", @@ -573,6 +572,9 @@ proc isJoinableSpec(spec: TSpec): bool = spec.outputCheck != ocSubstr and spec.ccodeCheck.len == 0 and (spec.targets == {} or spec.targets == {targetC}) + if result: + if spec.file.readFile.contains "when isMainModule": + result = false proc norm(s: var string) = while true: @@ -585,6 +587,13 @@ proc quoted(a: string): string = # todo: consider moving to system.nim result.addQuoted(a) +proc normalizeExe(file: string): string = + # xxx common pattern, should be exposed in std/os, even if simple (error prone) + when defined(posix): + if file.len == 0: "" + elif DirSep in file: file else: "./" & file + else: file + proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = ## returns a list of tests that have problems var specs: seq[TSpec] = @[] @@ -620,26 +629,24 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = for i, runSpec in specs: let file = runSpec.file - let file2 = outDir / ("megatest_" & $i & ".nim") + let file2 = outDir / ("megatest_$1.nim" % $i) # `include` didn't work with `trecmod2.nim`, so using `import` - let code = "echo \"" & marker & "\", " & quoted(file) & "\n" + let code = "echo \"$1\", $2\n" % [marker, quoted(file)] createDir(file2.parentDir) writeFile(file2, code) - megatest.add "import " & quoted(file2) & "\n" - megatest.add "import " & quoted(file) & "\n" - - writeFile("megatest.nim", megatest) + megatest.add "import $1\nimport $2\n" % [quoted(file2), quoted(file)] - let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", - "--listFullPaths:off", "--excessiveStackTrace:off", "megatest.nim"] + let megatestFile = testsDir / "megatest.nim" # so it uses testsDir / "config.nims" + writeFile(megatestFile, megatest) + let root = getCurrentDir() + let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "--path:" & root, megatestFile] var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "") if exitCode != 0: - echo "$ ", cmdLine - echo buf.string + echo "$ " & cmdLine & "\n" & buf.string quit("megatest compilation failed") - (buf, exitCode) = execCmdEx("./megatest") + (buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).normalizeExe) if exitCode != 0: echo buf.string quit("megatest execution failed") @@ -662,7 +669,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) = else: echo "output OK" removeFile("outputGotten.txt") - removeFile("megatest.nim") + removeFile(megatestFile) #testSpec r, makeTest("megatest", options, cat) # --------------------------------------------------------------------------- diff --git a/tests/stdlib/tcgi.nim b/tests/stdlib/tcgi.nim index bc177125e..7df1b077d 100644 --- a/tests/stdlib/tcgi.nim +++ b/tests/stdlib/tcgi.nim @@ -1,3 +1,9 @@ +discard """ + output: ''' +[Suite] Test cgi module +''' +""" + import unittest import cgi, strtabs diff --git a/tests/stdlib/tfdleak.nim b/tests/stdlib/tfdleak.nim index 5931be8c1..79d7ee0d0 100644 --- a/tests/stdlib/tfdleak.nim +++ b/tests/stdlib/tfdleak.nim @@ -2,6 +2,7 @@ discard """ exitcode: 0 output: "" matrix: "; -d:nimInheritHandles" + joinable: false """ import os, osproc, strutils, nativesockets, net, selectors, memfiles, diff --git a/tests/stdlib/tfdleak_multiple.nim b/tests/stdlib/tfdleak_multiple.nim index 75c4c0503..22387607f 100644 --- a/tests/stdlib/tfdleak_multiple.nim +++ b/tests/stdlib/tfdleak_multiple.nim @@ -1,3 +1,7 @@ +discard """ +joinable: false +""" + import os, osproc, strutils const Iterations = 200 diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim index a6fc6c1a5..118d0ae02 100644 --- a/tests/stdlib/tmarshal.nim +++ b/tests/stdlib/tmarshal.nim @@ -5,8 +5,13 @@ true alpha 100 omega 200 ''' +joinable: false """ +#[ +joinable: false pending https://github.com/nim-lang/Nim/issues/9754 +]# + import marshal template testit(x) = discard $$to[type(x)]($$x) diff --git a/tests/stdlib/tnetbind.nim b/tests/stdlib/tnetbind.nim index b2bcf4b05..734b6c5e7 100644 --- a/tests/stdlib/tnetbind.nim +++ b/tests/stdlib/tnetbind.nim @@ -1,3 +1,13 @@ +discard """ +joinable: false +""" + +#[ +joinable: false +otherwise: +Error: unhandled exception: Address already in use [OSError] +]# + import net ## Test for net.bindAddr diff --git a/tests/stdlib/tosproc.nim b/tests/stdlib/tosproc.nim index b5328c9eb..cb6e260c5 100644 --- a/tests/stdlib/tosproc.nim +++ b/tests/stdlib/tosproc.nim @@ -1,4 +1,11 @@ -# test the osproc module +discard """ +joinable: false +""" + +#[ +joinable: false +because it'd need cleanup up stdout +]# import stdtest/[specialpaths, unittest_light] diff --git a/tests/stdlib/trst.nim b/tests/stdlib/trst.nim index 6b1bd6897..797010a22 100644 --- a/tests/stdlib/trst.nim +++ b/tests/stdlib/trst.nim @@ -1,3 +1,9 @@ +discard """ + output: ''' +[Suite] RST include directive +''' +""" + # tests for rst module import ../../lib/packages/docutils/rstgen diff --git a/tests/stdlib/tstrutil.nim b/tests/stdlib/tstrutil.nim index cb6985a6e..5702b7341 100644 --- a/tests/stdlib/tstrutil.nim +++ b/tests/stdlib/tstrutil.nim @@ -1,6 +1,3 @@ -discard """ - output: "ha/home/a1xyz/usr/bin" -""" # test the new strutils module import @@ -15,7 +12,7 @@ template rejectParse(e) = except ValueError: discard proc testStrip() = - write(stdout, strip(" ha ")) + doAssert strip(" ha ") == "ha" proc testRemoveSuffix = var s = "hello\n\r" @@ -143,8 +140,9 @@ proc main() = testStrip() testRemoveSuffix() testRemovePrefix() - for p in split("/home/a1:xyz:/usr/bin", {':'}): - write(stdout, p) + var ret: seq[string] # or use `toSeq` + for p in split("/home/a1:xyz:/usr/bin", {':'}): ret.add p + doAssert ret == @["/home/a1", "xyz", "/usr/bin"] proc testDelete = var s = "0123456789ABCDEFGH" |