Filtering by module name

This commit is contained in:
Nathan McCarty 2025-01-26 15:23:38 -05:00
parent 75d955f666
commit f932ddcde5
2 changed files with 14 additions and 0 deletions

View file

@ -13,6 +13,7 @@ use IUtils::Compiler;
multi MAIN(
"test",
Str $project-path?, #= Base directory of the project, defaults to $*CWD
Str :module(:m(:$module-filter)), #= Module to run tests for
) {
# CD into the project path if needed
chdir($project-path.IO.resolve: :completely) if $project-path;
@ -24,6 +25,10 @@ multi MAIN(
my $basedir = $*CWD;
my $total-failures = 0;
for @runables -> $runable {
# Skip entirely if this runable doesn't contain the requested module
if $module-filter {
next unless $runable.contains-module: $module-filter;
}
my $package-failures = 0;
# Make sure the package is built
pack-build $runable.ipkg.relative;
@ -34,6 +39,10 @@ multi MAIN(
colored($runable.ipkg.relative($basedir), 'magenta bold');
say "{colored '*', 'yellow bold'} Testing $test-module-name";
for $runable.tests.keys -> $module-name {
# Skip this module if it's not the one we are looking for
if $module-name {
next unless $module-name eq $module-filter;
}
my $module-failures = 0;
my $module = $runable.tests{$module-name};
next unless $module.tests.elems > 0;