/**
This is a test-running script for libfossil/th1ish unit test.
Usage: ./th1ish THIS_FILE -- [--verbose] unit-test-script-file.th1ish ...more script files...
It runs each script, supressing normal output unless the --verbose
flag is provided. If any script throw an exception, processing
stops and this script re-throws that exception after console
restoring output.
The core test scripts are currently all named unit/???-???.th1ish, where
the ?s represent numbers.
*/
import("unit-common.th1ish");
scope {
//print(ARGV.flags, ARGV.nonFlags)
const flist = ARGV.nonFlags
const len = flist.length();
len || throw "Usage: "+ARGV.join(' ')+" -- SCRIPT FILE NAME(s)";
const banner = '**************************************************'
const blockOutput = !ARGV.flags.verbose
var _x = 0, err /*
reminder: name 'i' triggers an assertion in test 000-006,
and 'x' does the same in 000-004!
*/
for {var fname} {_x<len} {_x+=1} {
fname = flist.(_x)
print(banner," Running ",fname)
blockOutput && api.ob.push()
err = catch {import(fname)}
blockOutput && api.ob.pop()
err && break;
//print(banner," Done: ",fname);
}
err && throw err;
//print(__FILE,": Done!");
}