TIA: change detection misses all changes when the Pest project is a subdirectory of the git repository (monorepo)
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- git, php
- Ambito
- testing-qa
Direzione di ricerca
Start with src/Plugins/Tia/ChangedFiles.php and trace workingTreeChanges() and diffSinceSha(), then reproduce the monorepo case from the issue. Verify that Git paths from a repository-rooted command align with project-relative graph keys, that sibling paths are handled, and that the affected tests are rerun instead of replayed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened
In a monorepo where the Pest project lives in a subdirectory of the git repository (e.g. backend/), TIA never detects any PHP source change. In the worst case it replays the previous results as passing without executing the tests affected by the change.
repo/ <- git root
├── frontend/
└── backend/ <- Laravel app, composer.json, pest runs here
├── app/
└── tests/
Reproduction:
- Record a baseline:
PEST_ALLOW_XDEBUG=1 XDEBUG_MODE=coverage vendor/bin/pest --tia(frombackend/, all green, graph written). - Make a semantic change to
backend/app/Services/Billing/PartialInvoiceService.php(e.g. add aprivate const). - Run
vendor/bin/pest --tiaagain.
Expected: the tests covering that file are re-executed (in our suite: 40 tests across 4 files).
Actual: Tests: 1669 passed (…, 1669 replayed) in ~3s — the change maps to zero tests and everything is replayed as unchanged.
With no coverage driver loaded the failure is the safe-but-slow variant instead: WARN Detected PHP source changes but no coverage driver is available followed by a full-suite run on every invocation.
Root cause
src/Plugins/Tia/ChangedFiles.php collects changed paths via:
workingTreeChanges()→git status --porcelain -z --untracked-files=all(cwd = project root)diffSinceSha()→git diff --name-only <sha>..HEAD
Both git commands print paths relative to the repository root (backend/app/Services/...), regardless of cwd. Downstream these are consumed as project-relative paths:
currentHash()prepends the project root →…/backend/backend/app/...→is_file()false- the dependency-graph keys are project-relative (
app/Services/...) → the changed path never matches an edge → affected set is empty
Verified identical logic in v4.7.5 (installed) and v5.0.0 (GitHub source). Projects whose composer root equals the git root never notice, since both path notions coincide.
Proof it is exactly this
Creating a throwaway git repository inside backend/ (making project root == git root) and repeating the same experiment yields correct behavior immediately: Tests: 1669 passed (…, 40 affected, 1629 replayed) in ~100s. Removing the inner repo restores the broken behavior.
Suggested fix
Ask git for the prefix once (git rev-parse --show-prefix, empty at repo root) and strip it from every path returned by workingTreeChanges() / diffSinceSha() before they are compared with project-relative graph keys; paths outside the prefix (sibling packages, e.g. frontend/…) can be discarded or kept for the structural-change checks.
Environment
- Pest v4.7.5 (same code confirmed in v5.0.0)
- PHP 8.4.10, Laravel 12.64, PostgreSQL, macOS (darwin arm64)
- Layout: Laravel app in
backend/subdirectory of the git repo,tests/Pest.phpmapsTests\TestCaseonto Feature + Unit, suite is 100% functional Pest style (1669 tests)
- Lingua principale
- PHP
- Stelle
- 11.8k
- Fork
- 559
- Merge medio
- 5g 23h
- PR unite (30g)
- 24
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pestphp/pest
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: --mutate hides unreadable files, so mutants behind a failed read can never be killedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: [mutate] Windows: @pest-mutate-ignore comments land on line 1 in files with LF line endingsForse già presa @webdevsamran l’ha presa 57 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 5 giorni
-
[pest-plugin-browser] Page::waitForLoadState() never sends its message — waitForEvent() is a silent no-opForse già presa @asllanmaciel l’ha presa 70 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
pestphp/pest#1892 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di pestphp/pest
Issue simili
-
Group 2 - Data Storage | Tripal DBX | Chado Group 5 - Search | ElasticSearch | Views Priority - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
nginx update required due to NGINX2RootForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
mailcow/mailcow-dockerized#7668 · 5 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lara-zeus/spatie-translatable#80 ·
I maintainer di solito rispondono entro 1 giorno
-
small
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
uiowa/uiowa#10296 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
asyncapi/modelina#2709 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno