Skip to content

Commit 69a1ff0

Browse files
committed
Add TEST_THREADS env var support
1 parent bd07905 commit 69a1ff0

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

xt/space-after-comma.t

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ if @*ARGS {
2121
}
2222

2323
plan +@files;
24+
my $max-jobs = %*ENV<TEST_THREADS> // 2;
25+
my %output;
2426

25-
for @files -> $file {
26-
my $ok = True;
27-
28-
my $output = "";
27+
sub test-promise($promise) {
28+
my $file = $promise.command[*-1];
29+
test-it(%output{$file}, $file);
30+
}
2931

30-
if $file ~~ / '.pod6' $/ {
31-
my $a = Proc::Async.new($*EXECUTABLE-NAME, '--doc', $file);
32-
$a.stdout.tap(-> $buf { $output = $output ~ $buf });
33-
await $a.start;
34-
} else {
35-
$output = $file.IO.slurp;
36-
}
32+
sub test-it(Str $output, Str $file) {
33+
my $ok = True;
3734

3835
for $output.lines -> $line-orig {
3936
next if $line-orig ~~ / ^ ' '/;
@@ -64,4 +61,24 @@ for @files -> $file {
6461
ok $ok, "$error: Must have space after comma.";
6562
}
6663

64+
my @jobs;
65+
for @files -> $file {
66+
67+
my $output = "";
68+
69+
if $file ~~ / '.pod6' $/ {
70+
my $a = Proc::Async.new($*EXECUTABLE-NAME, '--doc', $file);
71+
%output{$file} = "";
72+
$a.stdout.tap(-> $buf { %output{$file} = %output{$file} ~ $buf });
73+
push @jobs: $a.start;
74+
if +@jobs > $max-jobs {
75+
test-promise(await @jobs.shift)
76+
}
77+
} else {
78+
test-it($file.IO.slurp, $file);
79+
}
80+
}
81+
82+
for @jobs.map: {await $_} -> $r { test-promise($r) }
83+
6784
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)