WIP, most tests are now skipped
This commit is contained in:
parent
7f6feb6034
commit
b26378a468
5 changed files with 169 additions and 164 deletions
|
|
@ -45,8 +45,7 @@ var
|
||||||
currentCategory: string
|
currentCategory: string
|
||||||
entries: int
|
entries: int
|
||||||
|
|
||||||
proc writeTestResult*(name, category, target,
|
proc writeTestResult*(name, category, target, result, expected, given: string) =
|
||||||
action, result, expected, given: string) =
|
|
||||||
createDir("testresults")
|
createDir("testresults")
|
||||||
if currentCategory != category:
|
if currentCategory != category:
|
||||||
if currentCategory.len > 0:
|
if currentCategory.len > 0:
|
||||||
|
|
@ -58,7 +57,7 @@ proc writeTestResult*(name, category, target,
|
||||||
entries = 0
|
entries = 0
|
||||||
|
|
||||||
let jentry = %*{"name": name, "category": category, "target": target,
|
let jentry = %*{"name": name, "category": category, "target": target,
|
||||||
"action": action, "result": result, "expected": expected, "given": given,
|
"result": result, "expected": expected, "given": given,
|
||||||
"machine": thisMachine.string, "commit": thisCommit.string, "branch": thisBranch}
|
"machine": thisMachine.string, "commit": thisCommit.string, "branch": thisBranch}
|
||||||
if entries > 0:
|
if entries > 0:
|
||||||
results.writeLine(",")
|
results.writeLine(",")
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ proc delNimCache(filename, options: string) =
|
||||||
proc runRodFiles(r: var TResults, cat: Category, options: string) =
|
proc runRodFiles(r: var TResults, cat: Category, options: string) =
|
||||||
template test(filename: string, clearCacheFirst=false) =
|
template test(filename: string, clearCacheFirst=false) =
|
||||||
if clearCacheFirst: delNimCache(filename, options)
|
if clearCacheFirst: delNimCache(filename, options)
|
||||||
testSpec r, makeTest(rodfilesDir / filename, options, cat, actionRun)
|
testSpec r, makeTest(rodfilesDir / filename, options, cat)
|
||||||
|
|
||||||
|
|
||||||
# test basic recompilation scheme:
|
# test basic recompilation scheme:
|
||||||
|
|
@ -97,10 +97,12 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) =
|
||||||
else:
|
else:
|
||||||
""
|
""
|
||||||
|
|
||||||
testNoSpec c, makeTest("lib/nimrtl.nim",
|
var test1 = makeTest("lib/nimrtl.nim", options & " --app:lib -d:createNimRtl --threads:on", cat)
|
||||||
options & " --app:lib -d:createNimRtl --threads:on", cat, actionCompile)
|
test1.spec.action = actionCompile
|
||||||
testNoSpec c, makeTest("tests/dll/server.nim",
|
testSpec c, test1
|
||||||
options & " --app:lib -d:useNimRtl --threads:on" & rpath, cat, actionCompile)
|
var test2 = makeTest("tests/dll/server.nim", options & " --app:lib -d:useNimRtl --threads:on" & rpath, cat)
|
||||||
|
test2.spec.action = actionCompile
|
||||||
|
testSpec c, test2
|
||||||
|
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
# windows looks in the dir of the exe (yay!):
|
# windows looks in the dir of the exe (yay!):
|
||||||
|
|
@ -120,7 +122,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) =
|
||||||
safeCopyFile("lib" / nimrtlDll, "tests/dll" / nimrtlDll)
|
safeCopyFile("lib" / nimrtlDll, "tests/dll" / nimrtlDll)
|
||||||
|
|
||||||
testSpec r, makeTest("tests/dll/client.nim", options & " -d:useNimRtl --threads:on" & rpath,
|
testSpec r, makeTest("tests/dll/client.nim", options & " -d:useNimRtl --threads:on" & rpath,
|
||||||
cat, actionRun)
|
cat)
|
||||||
|
|
||||||
proc dllTests(r: var TResults, cat: Category, options: string) =
|
proc dllTests(r: var TResults, cat: Category, options: string) =
|
||||||
# dummy compile result:
|
# dummy compile result:
|
||||||
|
|
@ -138,32 +140,32 @@ proc dllTests(r: var TResults, cat: Category, options: string) =
|
||||||
proc gcTests(r: var TResults, cat: Category, options: string) =
|
proc gcTests(r: var TResults, cat: Category, options: string) =
|
||||||
template testWithNone(filename: untyped) =
|
template testWithNone(filename: untyped) =
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" --gc:none", cat, actionRun)
|
" --gc:none", cat)
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" -d:release --gc:none", cat, actionRun)
|
" -d:release --gc:none", cat)
|
||||||
|
|
||||||
template testWithoutMs(filename: untyped) =
|
template testWithoutMs(filename: untyped) =
|
||||||
testSpec r, makeTest("tests/gc" / filename, options, cat, actionRun)
|
testSpec r, makeTest("tests/gc" / filename, options, cat)
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" -d:release", cat, actionRun)
|
" -d:release", cat)
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" -d:release -d:useRealtimeGC", cat, actionRun)
|
" -d:release -d:useRealtimeGC", cat)
|
||||||
|
|
||||||
template testWithoutBoehm(filename: untyped) =
|
template testWithoutBoehm(filename: untyped) =
|
||||||
testWithoutMs filename
|
testWithoutMs filename
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" --gc:markAndSweep", cat, actionRun)
|
" --gc:markAndSweep", cat)
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" -d:release --gc:markAndSweep", cat, actionRun)
|
" -d:release --gc:markAndSweep", cat)
|
||||||
template test(filename: untyped) =
|
template test(filename: untyped) =
|
||||||
testWithoutBoehm filename
|
testWithoutBoehm filename
|
||||||
when not defined(windows) and not defined(android):
|
when not defined(windows) and not defined(android):
|
||||||
# AR: cannot find any boehm.dll on the net, right now, so disabled
|
# AR: cannot find any boehm.dll on the net, right now, so disabled
|
||||||
# for windows:
|
# for windows:
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" --gc:boehm", cat, actionRun)
|
" --gc:boehm", cat)
|
||||||
testSpec r, makeTest("tests/gc" / filename, options &
|
testSpec r, makeTest("tests/gc" / filename, options &
|
||||||
" -d:release --gc:boehm", cat, actionRun)
|
" -d:release --gc:boehm", cat)
|
||||||
|
|
||||||
testWithoutBoehm "foreign_thr"
|
testWithoutBoehm "foreign_thr"
|
||||||
test "gcemscripten"
|
test "gcemscripten"
|
||||||
|
|
@ -196,17 +198,18 @@ proc longGCTests(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
||||||
var c = initResults()
|
var c = initResults()
|
||||||
# According to ioTests, this should compile the file
|
# According to ioTests, this should compile the file
|
||||||
testNoSpec c, makeTest("tests/realtimeGC/shared", options, cat, actionCompile)
|
testSpec c, makeTest("tests/realtimeGC/shared", options, cat)
|
||||||
testC r, makeTest("tests/realtimeGC/cmain", cOptions, cat, actionRun)
|
# ^- why is this not appended to r? Should this be discarded?
|
||||||
testSpec r, makeTest("tests/realtimeGC/nmain", options & "--threads: on", cat, actionRun)
|
testC r, makeTest("tests/realtimeGC/cmain", cOptions, cat), actionRun
|
||||||
|
testSpec r, makeTest("tests/realtimeGC/nmain", options & "--threads: on", cat)
|
||||||
|
|
||||||
# ------------------------- threading tests -----------------------------------
|
# ------------------------- threading tests -----------------------------------
|
||||||
|
|
||||||
proc threadTests(r: var TResults, cat: Category, options: string) =
|
proc threadTests(r: var TResults, cat: Category, options: string) =
|
||||||
template test(filename: untyped) =
|
template test(filename: untyped) =
|
||||||
testSpec r, makeTest(filename, options, cat, actionRun)
|
testSpec r, makeTest(filename, options, cat)
|
||||||
testSpec r, makeTest(filename, options & " -d:release", cat, actionRun)
|
testSpec r, makeTest(filename, options & " -d:release", cat)
|
||||||
testSpec r, makeTest(filename, options & " --tlsEmulation:on", cat, actionRun)
|
testSpec r, makeTest(filename, options & " --tlsEmulation:on", cat)
|
||||||
for t in os.walkFiles("tests/threads/t*.nim"):
|
for t in os.walkFiles("tests/threads/t*.nim"):
|
||||||
test(t)
|
test(t)
|
||||||
|
|
||||||
|
|
@ -235,10 +238,8 @@ proc debuggerTests(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
||||||
proc jsTests(r: var TResults, cat: Category, options: string) =
|
proc jsTests(r: var TResults, cat: Category, options: string) =
|
||||||
template test(filename: untyped) =
|
template test(filename: untyped) =
|
||||||
testSpec r, makeTest(filename, options & " -d:nodejs", cat,
|
testSpec r, makeTest(filename, options & " -d:nodejs", cat), {targetJS}
|
||||||
actionRun), targetJS
|
testSpec r, makeTest(filename, options & " -d:nodejs -d:release", cat), {targetJS}
|
||||||
testSpec r, makeTest(filename, options & " -d:nodejs -d:release", cat,
|
|
||||||
actionRun), targetJS
|
|
||||||
|
|
||||||
for t in os.walkFiles("tests/js/t*.nim"):
|
for t in os.walkFiles("tests/js/t*.nim"):
|
||||||
test(t)
|
test(t)
|
||||||
|
|
@ -259,14 +260,14 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
|
||||||
proc testNimInAction(r: var TResults, cat: Category, options: string) =
|
proc testNimInAction(r: var TResults, cat: Category, options: string) =
|
||||||
let options = options & " --nilseqs:on"
|
let options = options & " --nilseqs:on"
|
||||||
|
|
||||||
template test(filename: untyped, action: untyped) =
|
template test(filename: untyped) =
|
||||||
testSpec r, makeTest(filename, options, cat, action)
|
testSpec r, makeTest(filename, options, cat)
|
||||||
|
|
||||||
template testJS(filename: untyped) =
|
template testJS(filename: untyped) =
|
||||||
testSpec r, makeTest(filename, options, cat, actionCompile), targetJS
|
testSpec r, makeTest(filename, options, cat), {targetJS}
|
||||||
|
|
||||||
template testCPP(filename: untyped) =
|
template testCPP(filename: untyped) =
|
||||||
testSpec r, makeTest(filename, options, cat, actionCompile), targetCPP
|
testSpec r, makeTest(filename, options, cat), {targetCPP}
|
||||||
|
|
||||||
let tests = [
|
let tests = [
|
||||||
"niminaction/Chapter1/various1",
|
"niminaction/Chapter1/various1",
|
||||||
|
|
@ -318,7 +319,7 @@ proc testNimInAction(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
||||||
# Run the tests.
|
# Run the tests.
|
||||||
for testfile in tests:
|
for testfile in tests:
|
||||||
test "tests/" & testfile & ".nim", actionCompile
|
test "tests/" & testfile & ".nim"
|
||||||
|
|
||||||
let jsFile = "tests/niminaction/Chapter8/canvas/canvas_test.nim"
|
let jsFile = "tests/niminaction/Chapter8/canvas/canvas_test.nim"
|
||||||
testJS jsFile
|
testJS jsFile
|
||||||
|
|
@ -361,14 +362,17 @@ proc compileExample(r: var TResults, pattern, options: string, cat: Category) =
|
||||||
testNoSpec r, makeTest(test, options, cat)
|
testNoSpec r, makeTest(test, options, cat)
|
||||||
|
|
||||||
proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
|
proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
|
||||||
for test in os.walkFiles(pattern):
|
for testFile in os.walkFiles(pattern):
|
||||||
let name = extractFilename(test)
|
let name = extractFilename(testFile)
|
||||||
if name notin disabledFiles:
|
if name notin disabledFiles:
|
||||||
let contents = readFile(test).string
|
|
||||||
if contents.contains("when isMainModule"):
|
|
||||||
testSpec r, makeTest(test, options, cat, actionRunNoSpec)
|
let contents = readFile(testFile).string
|
||||||
else:
|
|
||||||
testNoSpec r, makeTest(test, options, cat, actionCompile)
|
var testObj = makeTest(testFile, options, cat)
|
||||||
|
if "when isMainModule" notin contents:
|
||||||
|
testObj.spec.action = actionCompile
|
||||||
|
testSpec r, testObj
|
||||||
|
|
||||||
# ----------------------------- nimble ----------------------------------------
|
# ----------------------------- nimble ----------------------------------------
|
||||||
type PackageFilter = enum
|
type PackageFilter = enum
|
||||||
|
|
@ -472,7 +476,7 @@ proc processSingleTest(r: var TResults, cat: Category, options, test: string) =
|
||||||
let test = "tests" & DirSep &.? cat.string / test
|
let test = "tests" & DirSep &.? cat.string / test
|
||||||
let target = if cat.string.normalize == "js": targetJS else: targetC
|
let target = if cat.string.normalize == "js": targetJS else: targetC
|
||||||
|
|
||||||
if existsFile(test): testSpec r, makeTest(test, options, cat), target
|
if existsFile(test): testSpec r, makeTest(test, options, cat), {target}
|
||||||
else: echo "[Warning] - ", test, " test does not exist"
|
else: echo "[Warning] - ", test, " test does not exist"
|
||||||
|
|
||||||
proc processCategory(r: var TResults, cat: Category, options: string) =
|
proc processCategory(r: var TResults, cat: Category, options: string) =
|
||||||
|
|
@ -521,8 +525,6 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
|
||||||
testNimblePackages(r, cat, pfAll)
|
testNimblePackages(r, cat, pfAll)
|
||||||
of "niminaction":
|
of "niminaction":
|
||||||
testNimInAction(r, cat, options)
|
testNimInAction(r, cat, options)
|
||||||
of "testament":
|
|
||||||
testTestament(r, cat, options)
|
|
||||||
of "untestable":
|
of "untestable":
|
||||||
# We can't test it because it depends on a third party.
|
# We can't test it because it depends on a third party.
|
||||||
discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.
|
discard # TODO: Move untestable tests to someplace else, i.e. nimble repo.
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
import parseutils, strutils, os, osproc, streams, parsecfg
|
import parseutils, strutils, os, osproc, streams, parsecfg
|
||||||
|
|
||||||
|
|
||||||
var compilerPrefix* = "compiler" / "nim"
|
var compilerPrefix* = "compiler" / "nim"
|
||||||
|
|
||||||
let isTravis* = existsEnv("TRAVIS")
|
let isTravis* = existsEnv("TRAVIS")
|
||||||
|
|
@ -97,32 +96,8 @@ proc extractSpec(filename: string): string =
|
||||||
when not defined(nimhygiene):
|
when not defined(nimhygiene):
|
||||||
{.pragma: inject.}
|
{.pragma: inject.}
|
||||||
|
|
||||||
template parseSpecAux(fillResult: untyped) =
|
proc defaultSpec*(): TSpec =
|
||||||
var ss = newStringStream(extractSpec(filename))
|
|
||||||
var p {.inject.}: CfgParser
|
|
||||||
open(p, ss, filename, 1)
|
|
||||||
while true:
|
|
||||||
var e {.inject.} = next(p)
|
|
||||||
case e.kind
|
|
||||||
of cfgEof: break
|
|
||||||
of cfgSectionStart, cfgOption, cfgError:
|
|
||||||
echo ignoreMsg(p, e)
|
|
||||||
of cfgKeyValuePair:
|
|
||||||
fillResult
|
|
||||||
close(p)
|
|
||||||
|
|
||||||
proc specDefaults*(result: var TSpec) =
|
|
||||||
result.msg = ""
|
|
||||||
result.outp = ""
|
|
||||||
result.nimout = ""
|
|
||||||
result.ccodeCheck = ""
|
|
||||||
result.cmd = cmdTemplate()
|
result.cmd = cmdTemplate()
|
||||||
result.line = 0
|
|
||||||
result.column = 0
|
|
||||||
result.tfile = ""
|
|
||||||
result.tline = 0
|
|
||||||
result.tcolumn = 0
|
|
||||||
result.maxCodeSize = 0
|
|
||||||
|
|
||||||
proc parseTargets*(value: string): set[TTarget] =
|
proc parseTargets*(value: string): set[TTarget] =
|
||||||
for v in value.normalize.splitWhitespace:
|
for v in value.normalize.splitWhitespace:
|
||||||
|
|
@ -134,79 +109,109 @@ proc parseTargets*(value: string): set[TTarget] =
|
||||||
else: echo "target ignored: " & v
|
else: echo "target ignored: " & v
|
||||||
|
|
||||||
proc parseSpec*(filename: string): TSpec =
|
proc parseSpec*(filename: string): TSpec =
|
||||||
specDefaults(result)
|
result = defaultSpec()
|
||||||
result.file = filename
|
result.file = filename
|
||||||
parseSpecAux:
|
var ss = newStringStream(extractSpec(filename))
|
||||||
case normalize(e.key)
|
var p {.inject.}: CfgParser
|
||||||
of "action":
|
open(p, ss, filename, 1)
|
||||||
case e.value.normalize
|
while true:
|
||||||
of "compile": result.action = actionCompile
|
var e = next(p)
|
||||||
of "run": result.action = actionRun
|
case e.kind
|
||||||
of "reject": result.action = actionReject
|
of cfgKeyValuePair:
|
||||||
else: echo ignoreMsg(p, e)
|
case normalize(e.key)
|
||||||
of "file": result.file = e.value
|
of "action":
|
||||||
of "line": discard parseInt(e.value, result.line)
|
case e.value.normalize
|
||||||
of "column": discard parseInt(e.value, result.column)
|
of "compile":
|
||||||
of "tfile": result.tfile = e.value
|
result.action = actionCompile
|
||||||
of "tline": discard parseInt(e.value, result.tline)
|
of "run":
|
||||||
of "tcolumn": discard parseInt(e.value, result.tcolumn)
|
result.action = actionRun
|
||||||
of "output":
|
of "reject":
|
||||||
result.outputCheck = ocEqual
|
result.action = actionReject
|
||||||
result.outp = strip(e.value)
|
else:
|
||||||
of "input":
|
echo ignoreMsg(p, e)
|
||||||
result.input = e.value
|
of "file":
|
||||||
of "outputsub":
|
result.file = e.value
|
||||||
result.outputCheck = ocSubstr
|
of "line":
|
||||||
result.outp = strip(e.value)
|
discard parseInt(e.value, result.line)
|
||||||
of "sortoutput":
|
of "column":
|
||||||
result.sortoutput = parseCfgBool(e.value)
|
discard parseInt(e.value, result.column)
|
||||||
of "exitcode":
|
of "tfile":
|
||||||
discard parseInt(e.value, result.exitCode)
|
result.tfile = e.value
|
||||||
result.action = actionRun
|
of "tline":
|
||||||
of "msg":
|
discard parseInt(e.value, result.tline)
|
||||||
result.msg = e.value
|
of "tcolumn":
|
||||||
if result.action != actionRun:
|
discard parseInt(e.value, result.tcolumn)
|
||||||
result.action = actionCompile
|
of "output":
|
||||||
of "errormsg", "errmsg":
|
result.outputCheck = ocEqual
|
||||||
result.msg = e.value
|
result.outp = strip(e.value)
|
||||||
result.action = actionReject
|
of "input":
|
||||||
of "nimout":
|
result.input = e.value
|
||||||
result.nimout = e.value
|
of "outputsub":
|
||||||
of "disabled":
|
result.outputCheck = ocSubstr
|
||||||
case e.value.normalize
|
result.outp = strip(e.value)
|
||||||
of "y", "yes", "true", "1", "on": result.err = reIgnored
|
of "sortoutput":
|
||||||
of "n", "no", "false", "0", "off": discard
|
result.sortoutput = parseCfgBool(e.value)
|
||||||
of "win", "windows":
|
of "exitcode":
|
||||||
when defined(windows): result.err = reIgnored
|
discard parseInt(e.value, result.exitCode)
|
||||||
of "linux":
|
result.action = actionRun
|
||||||
when defined(linux): result.err = reIgnored
|
of "msg":
|
||||||
of "bsd":
|
result.msg = e.value
|
||||||
when defined(bsd): result.err = reIgnored
|
if result.action != actionRun:
|
||||||
of "macosx":
|
result.action = actionCompile
|
||||||
when defined(macosx): result.err = reIgnored
|
of "errormsg", "errmsg":
|
||||||
of "unix":
|
result.msg = e.value
|
||||||
when defined(unix): result.err = reIgnored
|
result.action = actionReject
|
||||||
of "posix":
|
of "nimout":
|
||||||
when defined(posix): result.err = reIgnored
|
result.nimout = e.value
|
||||||
of "travis":
|
of "disabled":
|
||||||
if isTravis: result.err = reIgnored
|
case e.value.normalize
|
||||||
of "appveyor":
|
of "y", "yes", "true", "1", "on": result.err = reIgnored
|
||||||
if isAppVeyor: result.err = reIgnored
|
of "n", "no", "false", "0", "off": discard
|
||||||
|
of "win", "windows":
|
||||||
|
when defined(windows): result.err = reIgnored
|
||||||
|
of "linux":
|
||||||
|
when defined(linux): result.err = reIgnored
|
||||||
|
of "bsd":
|
||||||
|
when defined(bsd): result.err = reIgnored
|
||||||
|
of "macosx":
|
||||||
|
when defined(macosx): result.err = reIgnored
|
||||||
|
of "unix":
|
||||||
|
when defined(unix): result.err = reIgnored
|
||||||
|
of "posix":
|
||||||
|
when defined(posix): result.err = reIgnored
|
||||||
|
of "travis":
|
||||||
|
if isTravis: result.err = reIgnored
|
||||||
|
of "appveyor":
|
||||||
|
if isAppVeyor: result.err = reIgnored
|
||||||
|
else:
|
||||||
|
raise newException(ValueError, "cannot interpret as a bool: " & e.value)
|
||||||
|
of "cmd":
|
||||||
|
if e.value.startsWith("nim "):
|
||||||
|
result.cmd = compilerPrefix & e.value[3..^1]
|
||||||
|
else:
|
||||||
|
result.cmd = e.value
|
||||||
|
of "ccodecheck":
|
||||||
|
result.ccodeCheck = e.value
|
||||||
|
of "maxcodesize":
|
||||||
|
discard parseInt(e.value, result.maxCodeSize)
|
||||||
|
of "target", "targets":
|
||||||
|
for v in e.value.normalize.splitWhitespace:
|
||||||
|
case v
|
||||||
|
of "c":
|
||||||
|
result.targets.incl(targetC)
|
||||||
|
of "cpp", "c++":
|
||||||
|
result.targets.incl(targetCpp)
|
||||||
|
of "objc":
|
||||||
|
result.targets.incl(targetObjC)
|
||||||
|
of "js":
|
||||||
|
result.targets.incl(targetJS)
|
||||||
|
else:
|
||||||
|
echo ignoreMsg(p, e)
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError, "cannot interpret as a bool: " & e.value)
|
echo ignoreMsg(p, e)
|
||||||
of "cmd":
|
|
||||||
if e.value.startsWith("nim "):
|
of cfgSectionStart, cfgOption, cfgError:
|
||||||
result.cmd = compilerPrefix & e.value[3..^1]
|
echo ignoreMsg(p, e)
|
||||||
else:
|
of cfgEof:
|
||||||
result.cmd = e.value
|
break
|
||||||
of "ccodecheck": result.ccodeCheck = e.value
|
close(p)
|
||||||
of "maxcodesize": discard parseInt(e.value, result.maxCodeSize)
|
|
||||||
of "target", "targets":
|
|
||||||
for v in e.value.normalize.splitWhitespace:
|
|
||||||
case v
|
|
||||||
of "c": result.targets.incl(targetC)
|
|
||||||
of "cpp", "c++": result.targets.incl(targetCpp)
|
|
||||||
of "objc": result.targets.incl(targetObjC)
|
|
||||||
of "js": result.targets.incl(targetJS)
|
|
||||||
else: echo ignoreMsg(p, e)
|
|
||||||
else: echo ignoreMsg(p, e)
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ type
|
||||||
name: string
|
name: string
|
||||||
cat: Category
|
cat: Category
|
||||||
options: string
|
options: string
|
||||||
action: TTestAction
|
spec: TSpec
|
||||||
startTime: float
|
startTime: float
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
@ -113,7 +113,7 @@ proc nimcacheDir(filename, options: string, target: TTarget): string =
|
||||||
proc callCompiler(cmdTemplate, filename, options: string,
|
proc callCompiler(cmdTemplate, filename, options: string,
|
||||||
target: TTarget, extraOptions=""): TSpec =
|
target: TTarget, extraOptions=""): TSpec =
|
||||||
let nimcache = nimcacheDir(filename, options, target)
|
let nimcache = nimcacheDir(filename, options, target)
|
||||||
let options = options & " " & ("--nimCache:" & nimcache).quoteShell & extraOptions
|
let options = options & " " & quoteShell("--nimCache:" & nimcache) & extraOptions
|
||||||
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
|
||||||
"options", options, "file", filename.quoteShell,
|
"options", options, "file", filename.quoteShell,
|
||||||
"filedir", filename.getFileDir()])
|
"filedir", filename.getFileDir()])
|
||||||
|
|
@ -222,7 +222,6 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
||||||
backend.writeTestResult(name = name,
|
backend.writeTestResult(name = name,
|
||||||
category = test.cat.string,
|
category = test.cat.string,
|
||||||
target = $target,
|
target = $target,
|
||||||
action = $test.action,
|
|
||||||
result = $success,
|
result = $success,
|
||||||
expected = expected,
|
expected = expected,
|
||||||
given = given)
|
given = given)
|
||||||
|
|
@ -346,15 +345,10 @@ proc compilerOutputTests(test: TTest, target: TTarget, given: var TSpec,
|
||||||
r.addResult(test, target, expectedmsg, givenmsg, given.err)
|
r.addResult(test, target, expectedmsg, givenmsg, given.err)
|
||||||
|
|
||||||
proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
let tname = test.name.addFileExt(".nim")
|
var expected = test.spec
|
||||||
var expected: TSpec
|
|
||||||
if test.action != actionRunNoSpec:
|
|
||||||
expected = parseSpec(tname)
|
|
||||||
else:
|
|
||||||
specDefaults expected
|
|
||||||
expected.action = actionRunNoSpec
|
|
||||||
|
|
||||||
if expected.err == reIgnored:
|
if expected.err == reIgnored:
|
||||||
|
echo expected
|
||||||
# targetC is a lie
|
# targetC is a lie
|
||||||
r.addResult(test, targetC, "", "", reIgnored)
|
r.addResult(test, targetC, "", "", reIgnored)
|
||||||
inc(r.skipped)
|
inc(r.skipped)
|
||||||
|
|
@ -401,10 +395,10 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
|
||||||
let isJsTarget = target == targetJS
|
let isJsTarget = target == targetJS
|
||||||
var exeFile: string
|
var exeFile: string
|
||||||
if isJsTarget:
|
if isJsTarget:
|
||||||
let (_, file, _) = splitFile(tname)
|
let file = addFileExt(test.name, "js")
|
||||||
exeFile = nimcacheDir(test.name, test.options, target) / file & ".js"
|
exeFile = nimcacheDir(test.name, test.options, target) / file
|
||||||
else:
|
else:
|
||||||
exeFile = changeFileExt(tname, ExeExt)
|
exeFile = addFileExt(test.name, ExeExt)
|
||||||
|
|
||||||
if not existsFile(exeFile):
|
if not existsFile(exeFile):
|
||||||
r.addResult(test, target, expected.outp, "executable not found", reExeNotFound)
|
r.addResult(test, target, expected.outp, "executable not found", reExeNotFound)
|
||||||
|
|
@ -468,7 +462,7 @@ proc testNoSpec(r: var TResults, test: TTest, target = targetC) =
|
||||||
r.addResult(test, target, "", given.msg, given.err)
|
r.addResult(test, target, "", given.msg, given.err)
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
|
|
||||||
proc testC(r: var TResults, test: TTest) =
|
proc testC(r: var TResults, test: TTest, action: TTestAction) =
|
||||||
# runs C code. Doesn't support any specs, just goes by exit code.
|
# runs C code. Doesn't support any specs, just goes by exit code.
|
||||||
let tname = test.name.addFileExt(".c")
|
let tname = test.name.addFileExt(".c")
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
|
|
@ -476,7 +470,7 @@ proc testC(r: var TResults, test: TTest) =
|
||||||
var given = callCCompiler(cmdTemplate(), test.name & ".c", test.options, targetC)
|
var given = callCCompiler(cmdTemplate(), test.name & ".c", test.options, targetC)
|
||||||
if given.err != reSuccess:
|
if given.err != reSuccess:
|
||||||
r.addResult(test, targetC, "", given.msg, given.err)
|
r.addResult(test, targetC, "", given.msg, given.err)
|
||||||
elif test.action == actionRun:
|
elif action == actionRun:
|
||||||
let exeFile = changeFileExt(test.name, ExeExt)
|
let exeFile = changeFileExt(test.name, ExeExt)
|
||||||
var (_, exitCode) = execCmdEx(exeFile, options = {poStdErrToStdOut, poUsePath})
|
var (_, exitCode) = execCmdEx(exeFile, options = {poStdErrToStdOut, poUsePath})
|
||||||
if exitCode != 0: given.err = reExitCodesDiffer
|
if exitCode != 0: given.err = reExitCodesDiffer
|
||||||
|
|
@ -486,8 +480,7 @@ proc testExec(r: var TResults, test: TTest) =
|
||||||
# runs executable or script, just goes by exit code
|
# runs executable or script, just goes by exit code
|
||||||
inc(r.total)
|
inc(r.total)
|
||||||
let (outp, errC) = execCmdEx(test.options.strip())
|
let (outp, errC) = execCmdEx(test.options.strip())
|
||||||
var given: TSpec
|
var given: TSpec = defaultSpec()
|
||||||
specDefaults(given)
|
|
||||||
if errC == 0:
|
if errC == 0:
|
||||||
given.err = reSuccess
|
given.err = reSuccess
|
||||||
else:
|
else:
|
||||||
|
|
@ -497,8 +490,12 @@ proc testExec(r: var TResults, test: TTest) =
|
||||||
if given.err == reSuccess: inc(r.passed)
|
if given.err == reSuccess: inc(r.passed)
|
||||||
r.addResult(test, targetC, "", given.msg, given.err)
|
r.addResult(test, targetC, "", given.msg, given.err)
|
||||||
|
|
||||||
proc makeTest(test, options: string, cat: Category, env: string = ""): TTest =
|
proc makeTest(test, options: string, cat: Category): TTest =
|
||||||
result = TTest(cat: cat, name: test, options: options, startTime: epochTime())
|
result.cat = cat
|
||||||
|
result.name = test
|
||||||
|
result.options = options
|
||||||
|
result.spec = parseSpec(addFileExt(test, ".nim"))
|
||||||
|
result.startTime = epochTime()
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
const
|
const
|
||||||
|
|
@ -535,7 +532,8 @@ proc main() =
|
||||||
of "targets":
|
of "targets":
|
||||||
targetsStr = p.val.string
|
targetsStr = p.val.string
|
||||||
targets = parseTargets(targetsStr)
|
targets = parseTargets(targetsStr)
|
||||||
of "nim": compilerPrefix = p.val.string
|
of "nim":
|
||||||
|
compilerPrefix = p.val.string
|
||||||
of "directory":
|
of "directory":
|
||||||
setCurrentDir(p.val.string)
|
setCurrentDir(p.val.string)
|
||||||
of "colors":
|
of "colors":
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim $target --debuginfo --hints:on --app:lib $options $file"
|
cmd: "nim $target --debuginfo --hints:on --app:lib $options $file"
|
||||||
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import strutils
|
import strutils
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue