@@ -21,19 +21,16 @@ if @*ARGS {
21
21
}
22
22
23
23
plan + @ files ;
24
+ my $ max-jobs = % * ENV <TEST_THREADS > // 2 ;
25
+ my % output ;
24
26
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
+ }
29
31
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 ;
37
34
38
35
for $ output . lines -> $ line-orig {
39
36
next if $ line-orig ~~ / ^ ' ' /;
@@ -64,4 +61,24 @@ for @files -> $file {
64
61
ok $ ok , " $ error : Must have space after comma." ;
65
62
}
66
63
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
+
67
84
# vim: expandtab shiftwidth=4 ft=perl6
0 commit comments