File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77use Pest \Contracts \Plugins \HandlesOriginalArguments ;
88use Pest \Plugins \Concerns \HandleArguments ;
9+ use Pest \Plugins \Shard ;
910use Pest \Support \View ;
1011use Pest \TestSuite ;
1112use Pest \TypeCoverage \Contracts \Logger ;
1213use Pest \TypeCoverage \Logging \JsonLogger ;
1314use Pest \TypeCoverage \Logging \NullLogger ;
1415use Pest \TypeCoverage \Support \Cache ;
1516use Pest \TypeCoverage \Support \ConfigurationSourceDetector ;
17+ use Symfony \Component \Console \Input \ArgvInput ;
1618use Symfony \Component \Console \Output \OutputInterface ;
1719use Symfony \Component \Finder \Finder ;
1820
@@ -133,8 +135,25 @@ public function handleOriginalArguments(array $arguments): void
133135
134136 $ terminalWidth = terminal ()->width ();
135137
138+ $ input = new ArgvInput ($ arguments );
139+
140+ $ total = 1 ;
141+ $ index = 1 ;
142+
143+ if ($ input ->hasParameterOption ('--shard ' )) {
144+ ['index ' => $ index , 'total ' => $ total ] = Shard::getShard ($ input );
145+ }
146+
147+ $ files = iterator_to_array ($ files );
148+
149+ if ($ total > 1 ) {
150+ $ files = array_filter ($ files , static function ($ file ) use ($ index , $ total ): bool {
151+ return (crc32 ($ file ->getRealPath ()) % $ total ) === ($ index - 1 );
152+ });
153+ }
154+
136155 Analyser::analyse (
137- array_keys (iterator_to_array ( $ files) ),
156+ array_keys ($ files ),
138157 function (Result $ result ) use (&$ totals ): void {
139158 $ path = str_replace (TestSuite::getInstance ()->rootPath .'/ ' , '' , $ result ->file );
140159 $ uncoveredLines = [];
You can’t perform that action at this time.
0 commit comments