File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,26 @@ public function __construct(array $results)
25
25
$ this ->results = $ results ;
26
26
}
27
27
28
+ /**
29
+ * Determine if all of the processes in the pool were successful.
30
+ *
31
+ * @return bool
32
+ */
33
+ public function successful ()
34
+ {
35
+ return $ this ->collect ()->every (fn ($ p ) => $ p ->successful ());
36
+ }
37
+
38
+ /**
39
+ * Determine if any of the processes in the pool failed.
40
+ *
41
+ * @return bool
42
+ */
43
+ public function failed ()
44
+ {
45
+ return ! $ this ->successful ();
46
+ }
47
+
28
48
/**
29
49
* Get the results as a collection.
30
50
*
Original file line number Diff line number Diff line change @@ -47,6 +47,31 @@ public function testProcessPool()
47
47
48
48
$ this ->assertTrue (str_contains ($ results [0 ]->output (), 'ProcessTest.php ' ));
49
49
$ this ->assertTrue (str_contains ($ results [1 ]->output (), 'ProcessTest.php ' ));
50
+
51
+ $ this ->assertTrue ($ results ->successful ());
52
+ }
53
+
54
+ public function testProcessPoolFailed ()
55
+ {
56
+ $ factory = new Factory ;
57
+
58
+ $ factory ->fake ([
59
+ 'cat * ' => $ factory ->result (exitCode: 1 ),
60
+ ]);
61
+
62
+ $ pool = $ factory ->pool (function ($ pool ) {
63
+ return [
64
+ $ pool ->path (__DIR__ )->command ($ this ->ls ()),
65
+ $ pool ->path (__DIR__ )->command ('cat test ' ),
66
+ ];
67
+ });
68
+
69
+ $ results = $ pool ->start ()->wait ();
70
+
71
+ $ this ->assertTrue ($ results [0 ]->successful ());
72
+ $ this ->assertTrue ($ results [1 ]->failed ());
73
+
74
+ $ this ->assertTrue ($ results ->failed ());
50
75
}
51
76
52
77
public function testInvokedProcessPoolCount ()
You can’t perform that action at this time.
0 commit comments