Failure reporting

This commit is contained in:
Nathan McCarty 2024-12-31 20:00:20 +00:00
parent 013f8500df
commit c5ff918640

View file

@ -21,7 +21,9 @@ multi MAIN(
my @runables = @packages.map: *.runnables;
# Run the tests
my $basedir = $*CWD;
my $total-failures = 0;
for @runables -> $runable {
my $package-failures = 0;
# Make sure the package is built
pack-build $runable.ipkg.relative;
# CD to the local directory to make sure idris can exec the expressions
@ -31,6 +33,7 @@ multi MAIN(
colored($runable.ipkg.relative($basedir), 'magenta bold');
say "{colored '*', 'yellow bold'} Testing $test-module-name";
for $runable.tests.keys -> $module-name {
my $module-failures = 0;
my $module = $runable.tests{$module-name};
next unless $module.tests.elems > 0;
my $colored-module = colored $module-name, 'cyan bold';
@ -38,10 +41,12 @@ multi MAIN(
.indent(2);
for $module.tests -> $test {
try {
# FIXME this doesn't actually capture the exit code
idris-exec $test, $module.source.relative;
}
my $testf = colored $test, 'underline';
if $! {
$module-failures += 1;
my $stdout = $1.err.lines.map(*.indent(8)).join("\n");
say "{colored '+', 'red'} $testf: {colored 'FAIL', 'red bold'}"
.indent(4);
@ -55,7 +60,30 @@ multi MAIN(
.indent(4);
}
}
if $module-failures == 0 {
say "All $colored-module ".indent(4),
colored('tests passed', 'green underline');
} else {
say "$module-failures $colored-module ".indent(4),
colored('tests failed', 'red bold underline');
}
$package-failures += $module-failures;
}
if $package-failures == 0 {
say "All $test-module-name ".indent(2),
colored('tests passed', 'green underline');
} else {
say "$package-failures $test-module-name ".indent(2),
colored('tests failed', 'red bold underline');
}
$total-failures += $package-failures;
say '';
}
say '';
if $total-failures == 0 {
say 'All ', colored('tests passed', 'green underline');
} else {
say $total-failures, ' ', colored('tests failed', 'red bold underline');
}
}
}