blob: 67afb96cb1a41ea341650d92fa7087aeb70b69d6 (
plain)
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
39
40
41
42
43
44
45
46
|
#!/usr/bin/env nomsu -V6.13.12.8
#
Tool to run all tests in a file (i.e. the code block inside a call to 'test $'). Usage:
nomsu tools/test.nom file1 file2 directory1 ...
use "lib/os.nom"
use "lib/consolecolor.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Make sure all the files get run
for $filename in $(COMMAND LINE ARGS).extras: use $filename
$tests = {: for $s = $t in $TESTS: add (=lua "Source:from_string(\$s)") = $t}
for $filename in $(COMMAND LINE ARGS).extras:
$file = (read file $filename)
$version =
$file, matching ("
#![^
]* nomsu %-V[ ]*([^
]*)
")
$file_tests = []
for $src = $test in $tests:
if ($src.filename == $filename):
if $version:
$test = ("
#!/usr/bin/env nomsu -V\$version
\$test
")
$file_tests, add {.test = $test, .source = $src}
unless ($file_tests is empty):
sort $file_tests by $ -> $.source
lua> "io.write('[ .. ] ', \$filename); io.flush()"
if (command line args)."-v": say ""
for $ in $file_tests:
if (command line args)."-v":
say " \(yellow ($.test, with "\n" -> "\n "))"
run $.test
if (command line args)."-v":
say (green "PASS")
..else:
say "\r[\(green "PASS")"
|