Compare commits
No commits in common. "cab0cb5ce150e5330dcd19843bc153c7710ae69c" and "9bd0cc323f3dc800ab5d0331d8c2746d003596d9" have entirely different histories.
cab0cb5ce1
...
9bd0cc323f
3 changed files with 10 additions and 50 deletions
|
@ -7,8 +7,7 @@
|
||||||
"Nathan McCarty <thatonelutenist@stranger.systems>"
|
"Nathan McCarty <thatonelutenist@stranger.systems>"
|
||||||
],
|
],
|
||||||
"depends": [
|
"depends": [
|
||||||
"paths",
|
"paths"
|
||||||
"Terminal::ANSIColor"
|
|
||||||
],
|
],
|
||||||
"provides": {
|
"provides": {
|
||||||
"IUtils": "lib/IUtils.rakumod",
|
"IUtils": "lib/IUtils.rakumod",
|
||||||
|
|
56
bin/iutils
56
bin/iutils
|
@ -1,14 +1,10 @@
|
||||||
#!/usr/bin/env raku
|
#!/usr/bin/env raku
|
||||||
use v6.d;
|
use v6.d;
|
||||||
|
|
||||||
use Terminal::ANSIColor;
|
|
||||||
|
|
||||||
use IUtils;
|
use IUtils;
|
||||||
use IUtils::Regexes;
|
use IUtils::Regexes;
|
||||||
use IUtils::Compiler;
|
use IUtils::Compiler;
|
||||||
|
|
||||||
# TODO: Add filtering for tests based on module/name
|
# 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
|
#| Execute the tests in an idris project
|
||||||
multi MAIN(
|
multi MAIN(
|
||||||
"test",
|
"test",
|
||||||
|
@ -22,68 +18,34 @@ multi MAIN(
|
||||||
my @runables = @packages.map: *.runnables;
|
my @runables = @packages.map: *.runnables;
|
||||||
# Run the tests
|
# Run the tests
|
||||||
my $basedir = $*CWD;
|
my $basedir = $*CWD;
|
||||||
my $total-failures = 0;
|
|
||||||
for @runables -> $runable {
|
for @runables -> $runable {
|
||||||
my $package-failures = 0;
|
|
||||||
# Make sure the package is built
|
# Make sure the package is built
|
||||||
pack-build $runable.ipkg.relative;
|
pack-build $runable.ipkg.relative;
|
||||||
# CD to the local directory to make sure idris can exec the expressions
|
# CD to the local directory to make sure idris can exec the expressions
|
||||||
indir $runable.ipkg.parent, {
|
indir $runable.ipkg.parent, {
|
||||||
next unless $runable.tests.elems > 0;
|
next unless $runable.tests.elems > 0;
|
||||||
my $test-module-name =
|
say "** Testing {$runable.ipkg.relative: $basedir}";
|
||||||
colored($runable.ipkg.relative($basedir), 'magenta bold');
|
|
||||||
say "{colored '*', 'yellow bold'} Testing $test-module-name";
|
|
||||||
for $runable.tests.keys -> $module-name {
|
for $runable.tests.keys -> $module-name {
|
||||||
my $module-failures = 0;
|
|
||||||
my $module = $runable.tests{$module-name};
|
my $module = $runable.tests{$module-name};
|
||||||
next unless $module.tests.elems > 0;
|
next unless $module.tests.elems > 0;
|
||||||
my $colored-module = colored $module-name, 'cyan bold';
|
say "-- Testing $module-name".indent(2);
|
||||||
say "{colored '**', 'magenta bold'} Testing $colored-module"
|
|
||||||
.indent(2);
|
|
||||||
for $module.tests -> $test {
|
for $module.tests -> $test {
|
||||||
try {
|
try {
|
||||||
# FIXME this doesn't actually capture the exit code
|
|
||||||
idris-exec $test, $module.source.relative;
|
idris-exec $test, $module.source.relative;
|
||||||
}
|
}
|
||||||
my $testf = colored $test, 'underline';
|
|
||||||
if $! {
|
if $! {
|
||||||
# TODO: Don't show stdout if its empty
|
my $stdout = $1.err.lines.map(*.indent(8)).join("\n");
|
||||||
$module-failures += 1;
|
say "+ $test: FAIL".indent(4);
|
||||||
say "{colored '+', 'red'} $testf: {colored 'FAIL', 'red bold'}"
|
|
||||||
.indent(4);
|
|
||||||
say "stdout:".indent(6);
|
say "stdout:".indent(6);
|
||||||
say $!.err.lines.map(*.indent(8)).join("\n");
|
$!.err.lines.map(*.indent(8)).join("\n");
|
||||||
say (colored 'exit code', 'red').indent(6),
|
say "stderr:".indent(6);
|
||||||
": {$!.exit-code}";
|
$!.err.lines.map(*.indent(8)).join("\n");
|
||||||
|
say "exit code: {$!.exit-code}"
|
||||||
} else {
|
} else {
|
||||||
say "{colored '+', 'green'} $testf: {colored 'pass', 'green'}"
|
say "+ $test: Pass".indent(4);
|
||||||
.indent(4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if $module-failures == 0 {
|
|
||||||
say "All $colored-module ".indent(4),
|
|
||||||
colored('tests passed', 'green underline');
|
|
||||||
} else {
|
|
||||||
say "$module-failures $colored-module ".indent(4),
|
|
||||||
colored('tests failed', 'red bold underline');
|
|
||||||
}
|
|
||||||
$package-failures += $module-failures;
|
|
||||||
}
|
}
|
||||||
if $package-failures == 0 {
|
|
||||||
say "All $test-module-name ".indent(2),
|
|
||||||
colored('tests passed', 'green underline');
|
|
||||||
} else {
|
|
||||||
say "$package-failures $test-module-name ".indent(2),
|
|
||||||
colored('tests failed', 'red bold underline');
|
|
||||||
}
|
|
||||||
$total-failures += $package-failures;
|
|
||||||
say '';
|
|
||||||
}
|
|
||||||
say '';
|
|
||||||
if $total-failures == 0 {
|
|
||||||
say 'All ', colored('tests passed', 'green underline');
|
|
||||||
} else {
|
|
||||||
say $total-failures, ' ', colored('tests failed', 'red bold underline');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ sub idris-run(*@cmd) is export {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Special handling for IO Bool to make this eaiser
|
|
||||||
#| Exec the expression with the given name in the given file
|
#| Exec the expression with the given name in the given file
|
||||||
sub idris-exec($expr, $file) is export {
|
sub idris-exec($expr, $file) is export {
|
||||||
idris-run '--find-ipkg', '--exec', $expr, $file
|
idris-run '--find-ipkg', '--exec', $expr, $file
|
||||||
|
|
Loading…
Add table
Reference in a new issue