Login
7 branches 0 tags
Ben (X13/Void) Added array2d functions a4fe39f 4 years ago 258 Commits
nujel / tools / tests.nuj
#!/usr/bin/env nujel

[def test/beginning [time/milliseconds]]
[test-run]
[println [ansi-purple "Now running the AoC Tests, this might take a while."]]
[path/change "tests/"]

[def ext-nuj? [path/ext?! "nuj"]]
[defun directory/read-relative [path]
       [map [\ [α] [cat path "/" α]]
            [directory/read path]]
]

[def test/start [time/milliseconds]]
[def test/success 0]
[def test/errors 0]
[def i]
[defun file/test [path]
       [++ i]
       [try [\ [err]
               [newline]
	       [println [ansi-red path]]
	       [++ test/errors]
	       [display/error err]
               [newline]]
            [file/eval path [ω]]
            [++ test/success]
            [display [cat [ansi-green i] " "]]
       ]
]
[for-each file/test [filter ext-nuj? [directory/read-relative "."]]]
[newline]
[def dur [- [time/milliseconds] test/start]]
[if [and [> test/success 0] [zero? test/errors]]
    [do [println [cat [ansi-green "AoC Tests succeeded"] " - [" [ansi-green test/success] " / " [ansi-red test/errors] "] in " dur "ms"]]]
    [do [println [cat [ansi-red "AoC Tests failed"] " - [" [ansi-green test/success] " / " [ansi-red test/errors] "] in " dur "ms"]]]]

[println [cat "Running everything took " [ansi-blue [- [time/milliseconds] test/beginning]] "ms"]]
[exit test/errors]