Improve test running

Move test running to a method on the Test class and improve output
printing logic.
This commit is contained in:
Nathan McCarty 2024-12-31 19:08:42 -05:00
parent 09ac7506ee
commit 4b2c2eb4dd
3 changed files with 40 additions and 24 deletions

View file

@ -41,26 +41,7 @@ multi MAIN(
say "{colored '**', 'magenta bold'} Testing $colored-module"
.indent(2);
for $module.tests -> $test {
try {
# FIXME this doesn't actually capture the exit code
idris-exec $test.expr, $module.source.relative, $test.output-type;
}
my $testf = colored $test.name, 'underline';
if $! ~~ ExpressionError {
# TODO: Don't show stdout if its empty
$module-failures += 1;
say "{colored '+', 'red'} $testf: {colored 'FAIL', 'red bold'}"
.indent(4);
say "stdout:".indent(6);
say $!.err.lines.map(*.indent(8)).join("\n");
say (colored 'exit code', 'red').indent(6),
": {$!.exit-code}";
} elsif $! {
die $!;
} else {
say "{colored '+', 'green'} $testf: {colored 'pass', 'green'}"
.indent(4);
}
$module-failures += 1 if $test.run: $module.source;
}
if $module-failures == 0 {
say "All $colored-module ".indent(4),