diff --git a/.envrc b/.envrc deleted file mode 100644 index f1cd7c1..0000000 --- a/.envrc +++ /dev/null @@ -1,12 +0,0 @@ -use flake ~/Projects/Nix/system#idris2 - -export PACK_DIR=$PWD/.env/pack -export HEDGEHOG_COLOR=true - -PATH_add $PWD/.env/pack/bin -PATH_add $PWD/.scripts/bin - -export RAKUDO_LINE_EDITOR=Readline -export RAKULIB=$PWD/lib - -PATH_add ~/.raku/bin diff --git a/.gitignore b/.gitignore index ff5fe8a..a0dc5b9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tmp/ **/build/ **/.precomp/ .env +.envrc diff --git a/bin/iutils b/bin/iutils index a7334ad..7ba498e 100755 --- a/bin/iutils +++ b/bin/iutils @@ -7,12 +7,18 @@ use IUtils; use IUtils::Regexes; use IUtils::Compiler; +my %*SUB-MAIN-OPTS = + :named-anywhere, + :bundling, +; + # TODO: Add filtering for tests based on module/name # TODO: Move some of this functionality into methods for the relevant structs #| Execute the tests in an idris project 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 +30,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 +44,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 007c255..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, @@ -122,8 +127,12 @@ sub scan-ipkg(IO::Path:D $ipkg --> PackageInfo:D) { '"' $=[<-["]>*] '"' /) // "src"; + my sub is-source(Str:D $file --> Bool) { + return $file.ends-with(".idr") || $file.ends-with(".md"); + } + my IO::Path:D @sources = - paths($ipkg.parent.add($src-dir), :file(*.ends-with(".idr"))).map(*.IO); + paths($ipkg.parent.add($src-dir), :file(&is-source)).map(*.IO); PackageInfo.new(ipkg => $ipkg, root => $ipkg.parent, sources => @sources) } diff --git a/lib/IUtils/Regexes.rakumod b/lib/IUtils/Regexes.rakumod index 5ea28e1..fd2ae72 100644 --- a/lib/IUtils/Regexes.rakumod +++ b/lib/IUtils/Regexes.rakumod @@ -12,12 +12,12 @@ my token flag { \@ \@ } my token name { <[\w \-]>+ } my token test-name { \V+ } -my token comment-line { <&comment-start> \V* \v } +my token comment-line { \h* <&comment-start> \V* \v } my regex flagged-expression is export { \h* <&comment-start> \h* \h* \V* \v * - \h+ \: \h+ 'IO' \h+ \V* \v + \h* \h+ \: \h+ 'IO' \h+ \V* \v } my regex module-name is export {