Repository navigation
feat: let a shard unit bundle several test classes - #1829
maks-oleksyuk wants to merge 4 commits into
Conversation
fdb2ce8 to
d6b8986
Compare
|
thank you! can you rebase this? |
d6b8986 to
7d24ed8
Compare
|
Please update this branch against the latest |
7d24ed8 to
be2770a
Compare
MrPunyapal
left a comment
There was a problem hiding this comment.
Please address two regressions I reproduced with the sharding code on current 5.x.
- Drop deleted test classes from legacy timings before partitioning. With three live classes and a stale 100-second entry, shard 1 runs nothing and shard 2 runs all three files. Add a test for a removed class in
shards.json. - When removing
--coverage-phpfrom test discovery, consume its separate output path as well.--coverage-php pathcurrently leavespathas a positional test file, so discovery fails. Cover the space-separated form alongside the equals form.
Please also resolve the conflicts in tests/.snapshots/success.txt and tests/Visual/Parallel.php against current 5.x.
e1e9f1b to
570d767
Compare
|
Rebased onto the latest Both regressions are fixed:
Added tests for a removed class in the stored units and for the space-separated |
MrPunyapal
left a comment
There was a problem hiding this comment.
The original stale-class and --coverage-php path reproductions pass now. Please fix two remaining cases.
- Preserve units saved with
tests: []. The mutation plugin uses these units for ownership. Dropping them makesShard::owns()accept the missing unit on every shard. Add a test that distinguishes an explicitly empty unit from a unit emptied by removing stale classes. - Consume the separate values of
--coverage-jsonland--coverage-filterin discovery too. I reproduced--coverage-jsonl pathfailing with “Test file not found.” Add cases for both flags next to the--coverage-php pathtest.
570d767 to
d99fa42
Compare
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…option values Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…covery Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
d99fa42 to
475ccab
Compare
--shardsplits test classes and weighs each one on its own. That holds while a test class is the whole unit of work, but not when the work a shard has to do spans several of them: splitting those classes across shards duplicates the work and leaves every shard with a partial result.Mutation testing is the case that needs this. A mutation belongs to a source file, several test classes can cover that file, so the file is the unit and its covering test classes have to travel together. Related to #1691.
What changed
Shard::useTimings()accepts a richer value. Instead of a duration per test class, a unit may be['time' => float, 'tests' => list<string>]under any key. A bare float still means a test class bundling only itself, so an existingshards.jsonand the behaviour of a plain--update-shardsrun are unchanged.LPT partitioning now runs over units, and the
--filtera shard receives is the union of the test classes its units bundle.Shard::selectedUnits()exposes the keys allocated to the current shard, so a plugin can narrow the work it generates to match.Shard::useTimings()also takes optional metadata, stored next to the units and read back throughShard::metadata(). That lets a plugin carry a reference value from the unsharded run that produces the file into the sharded runs that consume it.Three smaller fixes ride along. The timings file is written when a plugin supplied the units and the run exits non-zero, so a job whose only purpose is to record timings is not lost to an unrelated failure. The count reported by
--update-shardsnow matches the number of entries actually written. The--list-testssubprocess no longer inherits--coveragearguments.Testing
tests/Unit/Plugins/Shard.phpcovers unit normalisation, partitioning that keeps a bundle intact, both file shapes on read and write, precedence of plugin-supplied units, and the zero entries written for test classes that produced no work of their own.Follow-ups
The plugin side that consumes this API lands in pestphp/pest-plugin-mutate#40. Together with #40 this closes the request in #1691.