From f932ddcde5524ffafda4f299733835a98a984f25 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sun, 26 Jan 2025 15:23:38 -0500 Subject: [PATCH] Filtering by module name --- bin/iutils | 9 +++++++++ lib/IUtils.rakumod | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/bin/iutils b/bin/iutils index a7334ad..ae04936 100755 --- a/bin/iutils +++ b/bin/iutils @@ -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; diff --git a/lib/IUtils.rakumod b/lib/IUtils.rakumod index 3ec2b99..0540148 100644 --- a/lib/IUtils.rakumod +++ b/lib/IUtils.rakumod @@ -69,6 +69,11 @@ class PackageRunables { # TODO: Add benchmarks #| A map from the name of the module to a list of tests has ModuleTests:D %.tests is required; + + #| Check to see if this package contains a given module + method contains-module(Str $module-name --> Bool) { + %!tests{$module-name}:exists + } } #| Structure representing the root of what idris considers a package directory,