-
Notifications
You must be signed in to change notification settings - Fork 14
/
runTests.nim
38 lines (32 loc) · 1.05 KB
/
runTests.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import
osproc,
os,
json,
strutils
var compiled = -1
for nimFile in walkDir("tests/"):
if nimFile.kind == pcFile and nimFile.path.endswith(".nim"):
compiled = execCmd("nim compile --verbosity:0 --hints:off --warnings:off " & nimFile.path)
if compiled != 0:
echo "Could not compile " & nimFile.path
quit(QuitFailure)
if compiled == 0:
var j = parseFile("tests/tests.json")
var exitTuple : tuple[output: string, exitCode: int]
for jo in j["tests"].items():
var cmd = "tests" / jo["file name"].str & " " & jo["args"].str
try:
exitTuple = execCmdEx(cmd)
doAssert(exitTuple.exitCode == jo["expect"].num)
if jo.hasKey("msg"): doAssert(jo["msg"].str == exitTuple.output)
write(stdout, ".")
except:
write(stdout, "F")
echo ""
echo "Test '", jo["test name"].str, "' failed."
echo "Ran " & cmd
echo "Expected: ", if jo.hasKey("msg"): repr(jo["msg"].str) else: $jo["expect"].num
echo "Got: ", repr(exitTuple.output)
quit(QuitFailure)
echo ""
echo "Tests pass!"