make tests/stdlib tests joinable (#14626)
* make tests/stdlib tests joinable * fixup
This commit is contained in:
parent
d51beb7b20
commit
49033eb531
9 changed files with 64 additions and 20 deletions
|
|
@ -35,7 +35,6 @@ const
|
||||||
"niminaction",
|
"niminaction",
|
||||||
"threads",
|
"threads",
|
||||||
"untestable",
|
"untestable",
|
||||||
"stdlib",
|
|
||||||
"testdata",
|
"testdata",
|
||||||
"nimcache",
|
"nimcache",
|
||||||
"coroutines",
|
"coroutines",
|
||||||
|
|
@ -573,6 +572,9 @@ proc isJoinableSpec(spec: TSpec): bool =
|
||||||
spec.outputCheck != ocSubstr and
|
spec.outputCheck != ocSubstr and
|
||||||
spec.ccodeCheck.len == 0 and
|
spec.ccodeCheck.len == 0 and
|
||||||
(spec.targets == {} or spec.targets == {targetC})
|
(spec.targets == {} or spec.targets == {targetC})
|
||||||
|
if result:
|
||||||
|
if spec.file.readFile.contains "when isMainModule":
|
||||||
|
result = false
|
||||||
|
|
||||||
proc norm(s: var string) =
|
proc norm(s: var string) =
|
||||||
while true:
|
while true:
|
||||||
|
|
@ -585,6 +587,13 @@ proc quoted(a: string): string =
|
||||||
# todo: consider moving to system.nim
|
# todo: consider moving to system.nim
|
||||||
result.addQuoted(a)
|
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) =
|
proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
## returns a list of tests that have problems
|
## returns a list of tests that have problems
|
||||||
var specs: seq[TSpec] = @[]
|
var specs: seq[TSpec] = @[]
|
||||||
|
|
@ -620,26 +629,24 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
|
|
||||||
for i, runSpec in specs:
|
for i, runSpec in specs:
|
||||||
let file = runSpec.file
|
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`
|
# `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)
|
createDir(file2.parentDir)
|
||||||
writeFile(file2, code)
|
writeFile(file2, code)
|
||||||
megatest.add "import " & quoted(file2) & "\n"
|
megatest.add "import $1\nimport $2\n" % [quoted(file2), quoted(file)]
|
||||||
megatest.add "import " & quoted(file) & "\n"
|
|
||||||
|
|
||||||
writeFile("megatest.nim", megatest)
|
let megatestFile = testsDir / "megatest.nim" # so it uses testsDir / "config.nims"
|
||||||
|
writeFile(megatestFile, megatest)
|
||||||
let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd",
|
|
||||||
"--listFullPaths:off", "--excessiveStackTrace:off", "megatest.nim"]
|
|
||||||
|
|
||||||
|
let root = getCurrentDir()
|
||||||
|
let args = ["c", "--nimCache:" & outDir, "-d:testing", "--listCmd", "--path:" & root, megatestFile]
|
||||||
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
|
var (cmdLine, buf, exitCode) = execCmdEx2(command = compilerPrefix, args = args, input = "")
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
echo "$ ", cmdLine
|
echo "$ " & cmdLine & "\n" & buf.string
|
||||||
echo buf.string
|
|
||||||
quit("megatest compilation failed")
|
quit("megatest compilation failed")
|
||||||
|
|
||||||
(buf, exitCode) = execCmdEx("./megatest")
|
(buf, exitCode) = execCmdEx(megatestFile.changeFileExt(ExeExt).normalizeExe)
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
echo buf.string
|
echo buf.string
|
||||||
quit("megatest execution failed")
|
quit("megatest execution failed")
|
||||||
|
|
@ -662,7 +669,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string) =
|
||||||
else:
|
else:
|
||||||
echo "output OK"
|
echo "output OK"
|
||||||
removeFile("outputGotten.txt")
|
removeFile("outputGotten.txt")
|
||||||
removeFile("megatest.nim")
|
removeFile(megatestFile)
|
||||||
#testSpec r, makeTest("megatest", options, cat)
|
#testSpec r, makeTest("megatest", options, cat)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
discard """
|
||||||
|
output: '''
|
||||||
|
[Suite] Test cgi module
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import cgi, strtabs
|
import cgi, strtabs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ discard """
|
||||||
exitcode: 0
|
exitcode: 0
|
||||||
output: ""
|
output: ""
|
||||||
matrix: "; -d:nimInheritHandles"
|
matrix: "; -d:nimInheritHandles"
|
||||||
|
joinable: false
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, osproc, strutils, nativesockets, net, selectors, memfiles,
|
import os, osproc, strutils, nativesockets, net, selectors, memfiles,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
discard """
|
||||||
|
joinable: false
|
||||||
|
"""
|
||||||
|
|
||||||
import os, osproc, strutils
|
import os, osproc, strutils
|
||||||
|
|
||||||
const Iterations = 200
|
const Iterations = 200
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,13 @@ true
|
||||||
alpha 100
|
alpha 100
|
||||||
omega 200
|
omega 200
|
||||||
'''
|
'''
|
||||||
|
joinable: false
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
#[
|
||||||
|
joinable: false pending https://github.com/nim-lang/Nim/issues/9754
|
||||||
|
]#
|
||||||
|
|
||||||
import marshal
|
import marshal
|
||||||
|
|
||||||
template testit(x) = discard $$to[type(x)]($$x)
|
template testit(x) = discard $$to[type(x)]($$x)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
discard """
|
||||||
|
joinable: false
|
||||||
|
"""
|
||||||
|
|
||||||
|
#[
|
||||||
|
joinable: false
|
||||||
|
otherwise:
|
||||||
|
Error: unhandled exception: Address already in use [OSError]
|
||||||
|
]#
|
||||||
|
|
||||||
import net
|
import net
|
||||||
|
|
||||||
## Test for net.bindAddr
|
## Test for net.bindAddr
|
||||||
|
|
|
||||||
|
|
@ -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]
|
import stdtest/[specialpaths, unittest_light]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
discard """
|
||||||
|
output: '''
|
||||||
|
[Suite] RST include directive
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
# tests for rst module
|
# tests for rst module
|
||||||
|
|
||||||
import ../../lib/packages/docutils/rstgen
|
import ../../lib/packages/docutils/rstgen
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
discard """
|
|
||||||
output: "ha/home/a1xyz/usr/bin"
|
|
||||||
"""
|
|
||||||
# test the new strutils module
|
# test the new strutils module
|
||||||
|
|
||||||
import
|
import
|
||||||
|
|
@ -15,7 +12,7 @@ template rejectParse(e) =
|
||||||
except ValueError: discard
|
except ValueError: discard
|
||||||
|
|
||||||
proc testStrip() =
|
proc testStrip() =
|
||||||
write(stdout, strip(" ha "))
|
doAssert strip(" ha ") == "ha"
|
||||||
|
|
||||||
proc testRemoveSuffix =
|
proc testRemoveSuffix =
|
||||||
var s = "hello\n\r"
|
var s = "hello\n\r"
|
||||||
|
|
@ -143,8 +140,9 @@ proc main() =
|
||||||
testStrip()
|
testStrip()
|
||||||
testRemoveSuffix()
|
testRemoveSuffix()
|
||||||
testRemovePrefix()
|
testRemovePrefix()
|
||||||
for p in split("/home/a1:xyz:/usr/bin", {':'}):
|
var ret: seq[string] # or use `toSeq`
|
||||||
write(stdout, p)
|
for p in split("/home/a1:xyz:/usr/bin", {':'}): ret.add p
|
||||||
|
doAssert ret == @["/home/a1", "xyz", "/usr/bin"]
|
||||||
|
|
||||||
proc testDelete =
|
proc testDelete =
|
||||||
var s = "0123456789ABCDEFGH"
|
var s = "0123456789ABCDEFGH"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue