mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
JS codegen enhancements; still unusable
This commit is contained in:
@@ -169,6 +169,22 @@ proc compileDebuggerTests(r: var TResults, options: string) =
|
||||
compileSingleTest(r, "tools/nimgrep", options &
|
||||
" --debugger:on")
|
||||
|
||||
# ------------------------- JS tests ------------------------------------------
|
||||
|
||||
proc runJsTests(r: var TResults, options: string) =
|
||||
template test(filename: expr): stmt =
|
||||
runSingleTest(r, filename, options & " -d:nodejs", targetJS)
|
||||
runSingleTest(r, filename, options & " -d:nodejs -d:release", targetJS)
|
||||
|
||||
# tactiontable, texceptions, texcpt1, texcsub, tfinally, tfinally2,
|
||||
# tfinally3
|
||||
for t in os.walkFiles("tests/js/t*.nim"):
|
||||
test(t)
|
||||
test "tests/run/tactiontable"
|
||||
test "tests/run/tmultim1"
|
||||
test "tests/run/tmultim3"
|
||||
test "tests/run/tmultim4"
|
||||
|
||||
# ------------------------- register special tests here -----------------------
|
||||
proc runSpecialTests(r: var TResults, options: string) =
|
||||
runRodFiles(r, options)
|
||||
|
||||
@@ -261,7 +261,10 @@ proc compileSingleTest(r: var TResults, test, options: string) =
|
||||
r.addResult(t, given.msg, if given.err: reFailure else: reSuccess)
|
||||
if not given.err: inc(r.passed)
|
||||
|
||||
proc runSingleTest(r: var TResults, test, options: string) =
|
||||
type
|
||||
TTarget = enum targetC, targetJS
|
||||
|
||||
proc runSingleTest(r: var TResults, test, options: string, target: TTarget) =
|
||||
var test = test.addFileExt(".nim")
|
||||
var t = extractFilename(test)
|
||||
echo t
|
||||
@@ -275,9 +278,16 @@ proc runSingleTest(r: var TResults, test, options: string) =
|
||||
if given.err:
|
||||
r.addResult(t, "", given.msg, reFailure)
|
||||
else:
|
||||
var exeFile = changeFileExt(test, ExeExt)
|
||||
var exeFile: string
|
||||
if target == targetC:
|
||||
exeFile = changeFileExt(test, ExeExt)
|
||||
else:
|
||||
let (dir, file, ext) = splitFile(test)
|
||||
exeFile = dir / "nimcache" / file & ".js"
|
||||
|
||||
if existsFile(exeFile):
|
||||
var (buf, exitCode) = execCmdEx(exeFile)
|
||||
var (buf, exitCode) = execCmdEx(
|
||||
(if target==targetJS: "node " else: "") & exeFile)
|
||||
if exitCode != expected.ExitCode:
|
||||
r.addResult(t, "exitcode: " & $expected.ExitCode,
|
||||
"exitcode: " & $exitCode, reFailure)
|
||||
@@ -291,6 +301,9 @@ proc runSingleTest(r: var TResults, test, options: string) =
|
||||
else:
|
||||
r.addResult(t, expected.outp, "executable not found", reFailure)
|
||||
|
||||
proc runSingleTest(r: var TResults, test, options: string) =
|
||||
runSingleTest(r, test, options, targetC)
|
||||
|
||||
proc run(r: var TResults, dir, options: string) =
|
||||
for test in os.walkFiles(dir / "t*.nim"): runSingleTest(r, test, options)
|
||||
|
||||
@@ -350,6 +363,12 @@ proc main() =
|
||||
run(runRes, "tests/run", p.cmdLineRest.string)
|
||||
runSpecialTests(runRes, p.cmdLineRest.string)
|
||||
writeResults(runJson, runRes)
|
||||
of "js":
|
||||
var runRes = initResults()
|
||||
if existsFile(runJSon):
|
||||
runRes = readResults(runJson)
|
||||
runJsTests(runRes, p.cmdLineRest.string)
|
||||
writeResults(runJson, runRes)
|
||||
of "merge":
|
||||
var rejectRes = readResults(rejectJson)
|
||||
var compileRes = readResults(compileJson)
|
||||
|
||||
Reference in New Issue
Block a user