diff --git a/src/Plugins/Shard.php b/src/Plugins/Shard.php index b08dd1dd..8c4fc0d8 100644 --- a/src/Plugins/Shard.php +++ b/src/Plugins/Shard.php @@ -139,7 +139,8 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable self::$timeBalanced = true; self::$shardsOutdated = $newTests !== []; } else { - $testsToRun = (array_chunk($tests, max(1, (int) ceil(count($tests) / $total))))[$index - 1] ?? []; + $isInCurrentShard = fn (int $key) => $key % $total === ($index - 1); + $testsToRun = array_values(array_filter(array_values($tests), $isInCurrentShard, ARRAY_FILTER_USE_KEY)); } self::$shard = [