@@ -41,6 +41,12 @@ abstract class BaseParallelTestManifest extends BaseTestManifest
4141 */
4242 protected $ dirPath ;
4343
44+ /**
45+ * An array of test name count in a single group
46+ * @var array
47+ */
48+ protected $ testCountsToGroup = [];
49+
4450 /**
4551 * BaseParallelTestManifest constructor.
4652 *
@@ -87,6 +93,8 @@ public function generate()
8793 foreach ($ this ->testGroups as $ groupNumber => $ groupContents ) {
8894 $ this ->generateGroupFile ($ groupContents , $ groupNumber , $ suites );
8995 }
96+
97+ $ this ->generateGroupSummaryFile ($ this ->testCountsToGroup );
9098 }
9199
92100 /**
@@ -114,17 +122,35 @@ protected function generateGroupFile($testGroup, $nodeNumber, $suites)
114122 foreach ($ testGroup as $ entryName => $ testValue ) {
115123 $ fileResource = fopen ($ this ->dirPath . DIRECTORY_SEPARATOR . "group {$ nodeNumber }.txt " , 'a ' );
116124
117- $ line = null ;
125+ $ this ->testCountsToGroup ["group {$ nodeNumber }" ] = $ this ->testCountsToGroup ["group {$ nodeNumber }" ] ?? 0 ;
126+
118127 if (!empty ($ suites [$ entryName ])) {
119128 $ line = "-g {$ entryName }" ;
129+ $ this ->testCountsToGroup ["group {$ nodeNumber }" ] += count ($ suites [$ entryName ]);
120130 } else {
121131 $ line = $ this ->relativeDirPath . DIRECTORY_SEPARATOR . $ entryName . '.php ' ;
132+ $ this ->testCountsToGroup ["group {$ nodeNumber }" ]++;
122133 }
123134 fwrite ($ fileResource , $ line . PHP_EOL );
124135 fclose ($ fileResource );
125136 }
126137 }
127138
139+ /**
140+ * @param array $groups
141+ * @return void
142+ */
143+ protected function generateGroupSummaryFile (array $ groups )
144+ {
145+ $ fileResource = fopen ($ this ->dirPath . DIRECTORY_SEPARATOR . "mftf_group_summary.txt " , 'w ' );
146+ $ contents = "Total Number of Groups: " . count ($ groups ) . PHP_EOL ;
147+ foreach ($ groups as $ key => $ value ) {
148+ $ contents .= $ key . " - " . $ value . " tests " .PHP_EOL ;
149+ }
150+ fwrite ($ fileResource , $ contents );
151+ fclose ($ fileResource );
152+ }
153+
128154 /**
129155 * Function which recusrively parses a given potentially multidimensional array of suites containing their split
130156 * groups. The result is a flattened array of suite names to relevant tests for generation of the manifest.
0 commit comments