Slightly colorized output

This commit is contained in:
Nathan McCarty 2024-12-31 19:32:50 +00:00
parent 9bd0cc323f
commit 013f8500df
2 changed files with 16 additions and 5 deletions

View file

@ -7,7 +7,8 @@
"Nathan McCarty <thatonelutenist@stranger.systems>" "Nathan McCarty <thatonelutenist@stranger.systems>"
], ],
"depends": [ "depends": [
"paths" "paths",
"Terminal::ANSIColor"
], ],
"provides": { "provides": {
"IUtils": "lib/IUtils.rakumod", "IUtils": "lib/IUtils.rakumod",

View file

@ -1,5 +1,8 @@
#!/usr/bin/env raku #!/usr/bin/env raku
use v6.d; use v6.d;
use Terminal::ANSIColor;
use IUtils; use IUtils;
use IUtils::Regexes; use IUtils::Regexes;
use IUtils::Compiler; use IUtils::Compiler;
@ -24,25 +27,32 @@ multi MAIN(
# CD to the local directory to make sure idris can exec the expressions # CD to the local directory to make sure idris can exec the expressions
indir $runable.ipkg.parent, { indir $runable.ipkg.parent, {
next unless $runable.tests.elems > 0; next unless $runable.tests.elems > 0;
say "** Testing {$runable.ipkg.relative: $basedir}"; my $test-module-name =
colored($runable.ipkg.relative($basedir), 'magenta bold');
say "{colored '*', 'yellow bold'} Testing $test-module-name";
for $runable.tests.keys -> $module-name { for $runable.tests.keys -> $module-name {
my $module = $runable.tests{$module-name}; my $module = $runable.tests{$module-name};
next unless $module.tests.elems > 0; next unless $module.tests.elems > 0;
say "-- Testing $module-name".indent(2); my $colored-module = colored $module-name, 'cyan bold';
say "{colored '**', 'magenta bold'} Testing $colored-module"
.indent(2);
for $module.tests -> $test { for $module.tests -> $test {
try { try {
idris-exec $test, $module.source.relative; idris-exec $test, $module.source.relative;
} }
my $testf = colored $test, 'underline';
if $! { if $! {
my $stdout = $1.err.lines.map(*.indent(8)).join("\n"); my $stdout = $1.err.lines.map(*.indent(8)).join("\n");
say "+ $test: FAIL".indent(4); say "{colored '+', 'red'} $testf: {colored 'FAIL', 'red bold'}"
.indent(4);
say "stdout:".indent(6); say "stdout:".indent(6);
$!.err.lines.map(*.indent(8)).join("\n"); $!.err.lines.map(*.indent(8)).join("\n");
say "stderr:".indent(6); say "stderr:".indent(6);
$!.err.lines.map(*.indent(8)).join("\n"); $!.err.lines.map(*.indent(8)).join("\n");
say "exit code: {$!.exit-code}" say "exit code: {$!.exit-code}"
} else { } else {
say "+ $test: Pass".indent(4); say "{colored '+', 'green'} $testf: {colored 'pass', 'green'}"
.indent(4);
} }
} }
} }