Somewhat working test running
This commit is contained in:
parent
49c118eef4
commit
9bd0cc323f
3 changed files with 82 additions and 7 deletions
41
bin/iutils
41
bin/iutils
|
@ -2,7 +2,9 @@
|
|||
use v6.d;
|
||||
use IUtils;
|
||||
use IUtils::Regexes;
|
||||
use IUtils::Compiler;
|
||||
|
||||
# TODO: Add filtering for tests based on module/name
|
||||
#| Execute the tests in an idris project
|
||||
multi MAIN(
|
||||
"test",
|
||||
|
@ -12,13 +14,38 @@ multi MAIN(
|
|||
chdir($project-path.IO.resolve: :completely) if $project-path;
|
||||
# Scan for our packages
|
||||
my @packages = scan-packages;
|
||||
# Collect tests
|
||||
my @tests;
|
||||
for @packages -> $package {
|
||||
# FIXME
|
||||
say 'Finding tests for ', $package.ipkg.relative;
|
||||
for $package.sources -> $source {
|
||||
say 'Scanning for tests in ', $source;
|
||||
# Collect runables
|
||||
my @runables = @packages.map: *.runnables;
|
||||
# Run the tests
|
||||
my $basedir = $*CWD;
|
||||
for @runables -> $runable {
|
||||
# Make sure the package is built
|
||||
pack-build $runable.ipkg.relative;
|
||||
# CD to the local directory to make sure idris can exec the expressions
|
||||
indir $runable.ipkg.parent, {
|
||||
next unless $runable.tests.elems > 0;
|
||||
say "** Testing {$runable.ipkg.relative: $basedir}";
|
||||
for $runable.tests.keys -> $module-name {
|
||||
my $module = $runable.tests{$module-name};
|
||||
next unless $module.tests.elems > 0;
|
||||
say "-- Testing $module-name".indent(2);
|
||||
for $module.tests -> $test {
|
||||
try {
|
||||
idris-exec $test, $module.source.relative;
|
||||
}
|
||||
if $! {
|
||||
my $stdout = $1.err.lines.map(*.indent(8)).join("\n");
|
||||
say "+ $test: FAIL".indent(4);
|
||||
say "stdout:".indent(6);
|
||||
$!.err.lines.map(*.indent(8)).join("\n");
|
||||
say "stderr:".indent(6);
|
||||
$!.err.lines.map(*.indent(8)).join("\n");
|
||||
say "exit code: {$!.exit-code}"
|
||||
} else {
|
||||
say "+ $test: Pass".indent(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue