mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
make tests/stdlib tests joinable (#14626)
* make tests/stdlib tests joinable * fixup
This commit is contained in:
@@ -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"
|
||||
megatest.add "import $1\nimport $2\n" % [quoted(file2), quoted(file)]
|
||||
|
||||
writeFile("megatest.nim", megatest)
|
||||
|
||||
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)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
discard """
|
||||
output: '''
|
||||
[Suite] Test cgi module
|
||||
'''
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import cgi, strtabs
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ discard """
|
||||
exitcode: 0
|
||||
output: ""
|
||||
matrix: "; -d:nimInheritHandles"
|
||||
joinable: false
|
||||
"""
|
||||
|
||||
import os, osproc, strutils, nativesockets, net, selectors, memfiles,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
joinable: false
|
||||
"""
|
||||
|
||||
import os, osproc, strutils
|
||||
|
||||
const Iterations = 200
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
discard """
|
||||
joinable: false
|
||||
"""
|
||||
|
||||
#[
|
||||
joinable: false
|
||||
otherwise:
|
||||
Error: unhandled exception: Address already in use [OSError]
|
||||
]#
|
||||
|
||||
import net
|
||||
|
||||
## 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]
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
discard """
|
||||
output: '''
|
||||
[Suite] RST include directive
|
||||
'''
|
||||
"""
|
||||
|
||||
# tests for rst module
|
||||
|
||||
import ../../lib/packages/docutils/rstgen
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user