#! /usr/bin/env -S nice raku use v6; use Shell::Piping; use Shell::Piping::Whereceptions; my int $exitcode = 0; multi sub MAIN(‚test‘, $dir = ‚.‘, Bool :$verbose?) { constant cores = $*KERNEL.cpu-cores - 1; constant NL = $?NL; my &RED = { „\e[31m$_\e[0m“ }; my &BOLD = { „\e[1m$_\e[0m“ }; &RED = &BOLD = { $_ } unless $*OUT.t; sub run-test(IO::Path $file where &it-is-a-file) { my @out; my @err; my $failed; px«raku -Ilib $file» |» @out :stderr(@err) :done({$exitcode ⚛= 1 if .exitcodes.so}); („Testing: {$file}“.&BOLD, @out, @err».&RED).flat.join(NL); } my \test-files = gather { for „$dir/t“.IO.d ?? „$dir/t“ !! $dir { if .IO.l && !.IO.e { warn „WARN: dangling symlink in ⟨$_⟩.“; next; } .take when .IO.extension eq ‚t‘ && !.IO.d; .IO.dir()».&?BLOCK when .IO.d; } } .put for test-files.sort.hyper(:batch(1), :degree(cores)).map(*.&run-test); exit $exitcode; } multi sub MAIN() { MAIN(‚test‘, ‚.‘) }