addQuitProc now works with closures, and c, js(node/browser) backend; fix some bugs in testament (#14342)
* make addQuitProc great again * fix bugs in testament * fix test * change 2016 => 2020 * addQuitProc => addExitProc + locks * move to std/exitprocs
This commit is contained in:
parent
45cac4afda
commit
dfe51d10a1
9 changed files with 117 additions and 44 deletions
|
|
@ -269,8 +269,8 @@ proc debuggerTests(r: var TResults, cat: Category, options: string) =
|
|||
|
||||
proc jsTests(r: var TResults, cat: Category, options: string) =
|
||||
template test(filename: untyped) =
|
||||
testSpec r, makeTest(filename, options & " -d:nodejs", cat), {targetJS}
|
||||
testSpec r, makeTest(filename, options & " -d:nodejs -d:release", cat), {targetJS}
|
||||
testSpec r, makeTest(filename, options, cat), {targetJS}
|
||||
testSpec r, makeTest(filename, options & " -d:release", cat), {targetJS}
|
||||
|
||||
for t in os.walkFiles("tests/js/t*.nim"):
|
||||
test(t)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,13 @@ const
|
|||
targetToExt*: array[TTarget, string] = ["nim.c", "nim.cpp", "nim.m", "js"]
|
||||
targetToCmd*: array[TTarget, string] = ["c", "cpp", "objc", "js"]
|
||||
|
||||
proc defaultOptions*(a: TTarget): string =
|
||||
case a
|
||||
of targetJS: "-d:nodejs"
|
||||
# once we start testing for `nim js -d:nimbrowser` (eg selenium or similar),
|
||||
# we can adapt this logic; or a given js test can override with `-u:nodejs`.
|
||||
else: ""
|
||||
|
||||
when not declared(parseCfgBool):
|
||||
# candidate for the stdlib:
|
||||
proc parseCfgBool(s: string): bool =
|
||||
|
|
|
|||
|
|
@ -135,7 +135,10 @@ proc nimcacheDir(filename, options: string, target: TTarget): string =
|
|||
|
||||
proc prepareTestArgs(cmdTemplate, filename, options, nimcache: string,
|
||||
target: TTarget, extraOptions = ""): seq[string] =
|
||||
let options = options & " " & quoteShell("--nimCache:" & nimcache) & " " & extraOptions
|
||||
var options = target.defaultOptions & " " & options
|
||||
# improve pending https://github.com/nim-lang/Nim/issues/14343
|
||||
if nimcache.len > 0: options.add " " & ("--nimCache:" & nimcache).quoteShell
|
||||
options.add " " & extraOptions
|
||||
result = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||
"options", options, "file", filename.quoteShell,
|
||||
"filedir", filename.getFileDir()])
|
||||
|
|
@ -192,9 +195,7 @@ proc callCompiler(cmdTemplate, filename, options, nimcache: string,
|
|||
|
||||
proc callCCompiler(cmdTemplate, filename, options: string,
|
||||
target: TTarget): TSpec =
|
||||
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||
"options", options, "file", filename.quoteShell,
|
||||
"filedir", filename.getFileDir()])
|
||||
let c = prepareTestArgs(cmdTemplate, filename, options, nimcache = "", target)
|
||||
var p = startProcess(command="gcc", args=c[5 .. ^1],
|
||||
options={poStdErrToStdOut, poUsePath})
|
||||
let outp = p.outputStream
|
||||
|
|
@ -254,7 +255,8 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
|||
# test.name is easier to find than test.name.extractFilename
|
||||
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
|
||||
var name = test.name.replace(DirSep, '/')
|
||||
name.add " " & $target & test.options
|
||||
name.add " " & $target
|
||||
if test.options.len > 0: name.add " " & test.options
|
||||
|
||||
let duration = epochTime() - test.startTime
|
||||
let success = if test.spec.timeout > 0.0 and duration > test.spec.timeout: reTimeout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue