Compare commits

...

6 commits

5 changed files with 27 additions and 15 deletions

12
.envrc
View file

@ -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

1
.gitignore vendored
View file

@ -7,3 +7,4 @@ tmp/
**/build/
**/.precomp/
.env
.envrc

View file

@ -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;

View file

@ -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) {
'"' $<value>=[<-["]>*] '"' /)<value>
// "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)
}

View file

@ -12,12 +12,12 @@ my token flag { \@ \@ <type> }
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* <flag> \h* <test-name> \V* \v
<comment-line>*
<expression-name=&name> \h+ \: \h+ 'IO' \h+ <output-type> \V* \v
\h* <expression-name=&name> \h+ \: \h+ 'IO' \h+ <output-type> \V* \v
}
my regex module-name is export {