From c5ff9186409083cbe46cf1b2414f2f9743aa6406 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Tue, 31 Dec 2024 20:00:20 +0000 Subject: [PATCH] Failure reporting --- bin/iutils | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bin/iutils b/bin/iutils index 29a6357..f0076e8 100755 --- a/bin/iutils +++ b/bin/iutils @@ -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'); } } }