pestphp / pestphp/pest

[Bug]: Sharding in modular apps

Open Beginner friendly
#1,445 9 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.