forked from hoelzro/p6-algorithm-lcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests
65 lines (55 loc) · 1.51 KB
/
run-tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
unit sub MAIN(:a($author), :i($install));
say run(<raku --version>, :out).out.slurp.chomp;
say "Running on $*DISTRO.gist().\n";
say "Testing {
"dist.ini".IO.lines.head.substr(7)
}{
" including author tests" if $author
}";
my @failed;
my $done = 0;
sub process($proc, $filename) {
if $proc {
$proc.out.slurp;
}
else {
@failed.push($filename);
if $proc.out.slurp -> $stdout {
my @lines = $stdout.lines;
with @lines.first(
*.starts-with(" from gen/moar/stage2"),:k)
-> $index {
say @lines[^$index].join("\n");
}
else {
say $stdout;
}
}
else {
say "No output received, exit-code $proc.exitcode() ($proc.signal()):\n$proc.os-error()";
}
}
}
sub install() {
my $zef := $*DISTRO.is-win ?? 'zef.bat' !! 'zef';
my $proc := run $zef, "install", ".", "--verbose", "--/test", :out,:err,:merge;
process($proc, "*installation*");
}
sub test-dir($dir) {
for $dir.IO.dir(:test(*.ends-with: '.t' | '.rakutest')).map(*.Str).sort {
say "=== $_";
my $proc := run "raku", "--ll-exception", "-I.", $_, :out,:err,:merge;
process($proc, $_);
$done++;
}
}
test-dir("t");
test-dir("xt") if $author && "xt".IO.e;
install if $install;
if @failed {
say "\nFAILED: {+@failed} of $done:";
say " $_" for @failed;
exit +@failed;
}
say "\nALL {"$done " if $done > 1}OK";
# vim: expandtab shiftwidth=4