2626use PHPUnit \Framework \DataProviderTestSuite ;
2727use PHPUnit \Framework \IterativeTestSuite ;
2828use PHPUnit \Framework \PhptIterativeTestSuite ;
29+ use PHPUnit \Framework \PhptRepeatTestSuite ;
30+ use PHPUnit \Framework \PhptRetryTestSuite ;
2931use PHPUnit \Framework \Test ;
3032use PHPUnit \Framework \TestCase ;
3133use PHPUnit \Framework \TestRunner \ChildProcessResultProcessor ;
@@ -896,7 +898,7 @@ private function collectUnits(TestSuite $suite, int &$index): array
896898 /** @var array<class-string<TestCase>, array{index: non-negative-int, tests: list<DataProviderTestSuite|IterativeTestSuite|TestCase>}> $byClass */
897899 $ byClass = [];
898900
899- /** @var list<array{index: non-negative-int, file: non-empty-string, conflicts: list<non-empty-string>}> $phpt */
901+ /** @var list<array{index: non-negative-int, file: non-empty-string, conflicts: list<non-empty-string>, numberOfRuns: positive-int, maxAttempts: positive-int }> $phpt */
900902 $ phpt = [];
901903
902904 /** @var list<array{index: non-negative-int, test: Test}> $standalone */
@@ -913,7 +915,13 @@ private function collectUnits(TestSuite $suite, int &$index): array
913915 $ phptUnits = [];
914916
915917 foreach ($ phpt as $ item ) {
916- $ phptUnits [] = new PhptWorkUnit ($ item ['index ' ], $ item ['file ' ], $ item ['conflicts ' ]);
918+ $ phptUnits [] = new PhptWorkUnit (
919+ $ item ['index ' ],
920+ $ item ['file ' ],
921+ $ item ['conflicts ' ],
922+ $ item ['numberOfRuns ' ],
923+ $ item ['maxAttempts ' ],
924+ );
917925 }
918926
919927 return [
@@ -924,10 +932,10 @@ private function collectUnits(TestSuite $suite, int &$index): array
924932 }
925933
926934 /**
927- * @param array<class-string<TestCase>, array{index: non-negative-int, tests: list<DataProviderTestSuite|IterativeTestSuite|TestCase>}> $byClass
928- * @param list<array{index: non-negative-int, file: non-empty-string, conflicts: list<non-empty-string>}> $phpt
929- * @param list<array{index: non-negative-int, test: Test}> $standalone
930- * @param non-negative-int $index
935+ * @param array<class-string<TestCase>, array{index: non-negative-int, tests: list<DataProviderTestSuite|IterativeTestSuite|TestCase>}> $byClass
936+ * @param list<array{index: non-negative-int, file: non-empty-string, conflicts: list<non-empty-string>, numberOfRuns: positive-int, maxAttempts: positive-int}> $phpt
937+ * @param list<array{index: non-negative-int, test: Test}> $standalone
938+ * @param non-negative-int $index
931939 */
932940 private function collect (TestSuite $ suite , array &$ byClass , array &$ phpt , array &$ standalone , int &$ index ): void
933941 {
@@ -941,13 +949,32 @@ private function collect(TestSuite $suite, array &$byClass, array &$phpt, array
941949 }
942950
943951 // The repetitions of a repeated PHPT test and the attempts of a
944- // retried PHPT test are orchestrated by their suite's runTests()
945- // method and must run sequentially, so the suite runs as one unit
946- // in the main process at its suite index.
952+ // retried PHPT test must run one after another, so the suite that
953+ // orchestrates them becomes one PHPT unit rather than one unit per
954+ // run: the runner rebuilds the suite from the unit and advances it
955+ // as a whole, alongside the other PHPT tests.
947956 if ($ test instanceof PhptIterativeTestSuite) {
948- $ standalone [] = [
949- 'index ' => $ index ,
950- 'test ' => $ test ,
957+ $ file = $ test ->name ();
958+
959+ assert ($ file !== '' );
960+
961+ $ numberOfRuns = 1 ;
962+ $ maxAttempts = 1 ;
963+
964+ if ($ test instanceof PhptRepeatTestSuite) {
965+ $ numberOfRuns = $ test ->numberOfRuns ();
966+ } else {
967+ assert ($ test instanceof PhptRetryTestSuite);
968+
969+ $ maxAttempts = $ test ->maxAttempts ();
970+ }
971+
972+ $ phpt [] = [
973+ 'index ' => $ index ,
974+ 'file ' => $ file ,
975+ 'conflicts ' => $ this ->phptConflicts ($ file ),
976+ 'numberOfRuns ' => $ numberOfRuns ,
977+ 'maxAttempts ' => $ maxAttempts ,
951978 ];
952979
953980 $ index ++;
@@ -1008,9 +1035,11 @@ private function collect(TestSuite $suite, array &$byClass, array &$phpt, array
10081035 // --CONFLICTS-- section. The runner honours those conflict keys
10091036 // while running the PHPT tests concurrently in the main process.
10101037 $ phpt [] = [
1011- 'index ' => $ index ,
1012- 'file ' => $ file ,
1013- 'conflicts ' => $ this ->phptConflicts ($ file ),
1038+ 'index ' => $ index ,
1039+ 'file ' => $ file ,
1040+ 'conflicts ' => $ this ->phptConflicts ($ file ),
1041+ 'numberOfRuns ' => 1 ,
1042+ 'maxAttempts ' => 1 ,
10141043 ];
10151044
10161045 $ index ++;
0 commit comments