-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntest.raku
More file actions
executable file
·42 lines (35 loc) · 992 Bytes
/
runtest.raku
File metadata and controls
executable file
·42 lines (35 loc) · 992 Bytes
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
#!/usr/bin/env raku
use Test;
use JSON::Fast;
use fatal;
my @specs = from-json(slurp 'test/run/spec.json');
for @specs -> % (:$name, :$is-error, :$skip, :@dependencies) {
if $skip {
skip "Skipping $name" ~ (" - $skip" if $skip ~~ Str);
next;
}
my $bc-file = "test/run/$name.bc.json";
my $expected-output = slurp("test/run/$name.output");
my @output;
my $error;
@dependencies.=map({ "test/run/$_.bc.json" });
my $proc = Proc::Async.new('cargo', 'run', $bc-file, |@dependencies);
$proc.stdout.tap({ @output.push: $_ });
$proc.stderr.tap({ $error ~= $_ });
try {
my $r = await $proc.start;
if $is-error {
if $r.exitcode {
ok $error ~~ /$expected-output/, $name;
} else {
flunk "Expected error in $name";
}
} else {
if $r.exitcode {
diag "ERRORS:\n" ~ $error.lines.map("ERR: " ~ *).join("\n").indent(2);
flunk $name;
}
is @output.join("\n"), $expected-output, $name;
}
}
}