fix(shard): make time-based sharding namespace-agnostic and forward --test-directory#1677
Open
norbybaru wants to merge 11 commits intopestphp:4.xfrom
Open
fix(shard): make time-based sharding namespace-agnostic and forward --test-directory#1677norbybaru wants to merge 11 commits intopestphp:4.xfrom
norbybaru wants to merge 11 commits intopestphp:4.xfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The removeParallelArguments method was not filtering --processes flags, causing the list-tests subprocess to fail when parallel execution was enabled. This prevented time-based sharding from working correctly with the --parallel option. Now both --parallel/-p and --processes arguments are removed from the command used to enumerate tests, ensuring the subprocess runs successfully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
Description:
Time-based sharding (#1671) silently fails for projects whose tests do not live under the
Tests\namespace.Root cause 1 — hardcoded namespace in regex (
Shard.php:196):The
allTests()method parses--list-testsoutput using a regex that only captures FQCNs starting withTests\:For any other namespace (
App\Tests\,Acme\Suite\, etc.),allTests()returns[], causing:--update-shardswrites an emptyshards.jsonarray_chunkRoot cause 2 —
--test-directorynot forwarded to subprocess:bin/peststrips--test-directoryfrom argv before the plugin pipeline runs (lines 42-50).Shard::allTests()spawns a subprocess with those stripped arguments, so the subprocess alwaysdefaults to the
tests/directory — even when users configure a custom test path.Solution
1. Namespace-agnostic regex
Replaced
Tests\\-hardcoded regex with a pattern matching any valid PHP FQCN:Matches sequences of valid PHP identifiers joined by
\. Stricter than a catch-all[^:]+— rejects whitespace, punctuation, and malformed lines.2. Forward
--test-directoryto the subprocessRead the already-resolved test path from the
TestSuitesingleton and inject it into the subprocess command: