[Bug]: Sharding in modular apps
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.7k
- Forks
- 538
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 8
Description
What Happened
Right now, when tests are spread across modules in the app and not in the tests directory, while sharding, all the tests are running for each shard.
In here, the pattern only detects the tests that are starting with the Tests\ namespace
https://github.com/pestphp/pest/blob/a7b2039175926804e7f3b5c043e632644c5bc8ef/src/Plugins/Shard.php#L92
But when you change the line to
preg_match_all('/ - (?:P\\\\)?(.+)::/', $output, $matches);
It works, but the reason I did not submit a PR was that in this https://github.com/pestphp/pest/commit/5def62018b19b8a9fc6bdc410f6a48925a1b9d51 commit, you have changed the same thing, and because I didn't know the reason, I decided to submit an issue instead.
How to Reproduce
Put tests in any directory other than tests
Sample Repository
No response
Pest Version
4.0.0
PHP Version
8.3
Operation System
Linux, Windows
Notes
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Plugins/Shard.php around line 92 and compare the current pattern with commit 5def62018b19b8a9fc6bdc410f6a48925a1b9d51 to understand why the namespace restriction was introduced. Reproduce the issue with tests outside the tests directory, then verify that sharding discovers those tests without breaking existing test discovery.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100