* fix(tia): support a Pest project nested in a git repository
Tia refused to run whenever the Pest project was not the git repository
root, because git prints and addresses paths relative to the repository
root while the dependency graph is keyed on project-relative paths.
Translate at every git boundary instead of guarding against the mismatch.
`Git::pathPrefix()` resolves the directory of the project inside the
repository, and `ChangedFiles` strips that prefix off the paths git prints,
drops the paths of sibling packages, and prepends it to `git show`. Both
diffs read `-z` records, because `core.quotePath` C-quotes a path outside
ASCII, and `--no-relative` holds the frame when a user sets `diff.relative`.
Three places read `<projectRoot>/.git` directly, which is absent in a
nested project and in a worktree, and now ask git: `BaseRemote`, `Storage`
and `Fingerprint::isTrackedByGit()`. `Storage` folds the prefix into the
state key so two projects in one repository do not share a graph, and the
fingerprint carries the prefix so a baseline published by a sibling project
is rejected. A project at the repository root keeps the key and the
fingerprint it had.
`git check-ignore` runs without `--no-index`, so a tracked file that an
ignore rule matches counts as part of the project on both sides of the
boundary.
Changes outside the project are dropped and reported by count in the run
summary, so a nested project does not look idle when the repository around
it moved.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(tia): keep whitespace at the edge of the paths git returns
* fix(tia): run the full suite when a PHP file outside a nested project changes
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): free the ReadCapture wrapper each time it steps aside
stream_wrapper_restore() takes a user wrapper out of the wrapper table
but does not free it, so every filesystem call made while a test records
kept one until the process ended. Unregistering it first frees it.
* fix(tia): skip the unregister when file:// is already gone
A test can unregister file:// itself. stream_wrapper_unregister() then
warns, where stream_wrapper_restore() alone did not, so check first.
Also run the per-test memory check over 5,000 tests and update the
snapshot and parallel totals for the new tests.
* Use fopen() in the memory regression test
---------
Co-authored-by: Mohannad Elemary <20709195+MohannadElemary@users.noreply.github.com>
* feat: let a shard unit bundle several test classes
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: own unknown shard units in every shard and clean up worker timings
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix: drop removed test classes from shard units and consume coverage option values
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix: preserve empty shard units and consume more option values in discovery
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* Stat once in ReadCapture url_stat
* Keep quiet url_stat probes away from error handlers
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: beforeEach/afterEach leaking into sibling describe blocks with same nested name
* fix: resolve afterEach test ordering issue
* chore: update snapshots and parallel memory limit after rebase onto upstream/5.x
* chore: update snapshots and parallel memory limit after rebase onto upstream/5.x
---------
Co-authored-by: Adam Goulding <adam.goulding@ethixbase360.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* feat: convert namespace-style arguments to file paths in pest binary
* test: allow running a single test using its namespace
* fix: preserve namespace filters when converting arguments
* test: update success snapshot for namespace filters
* fix: convert namespace after retry flag
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: honor all stop-on-* flags in parallel mode
Previously --stop-on-failure was the only flag honored in parallel
mode, and it only cleared pending tests when the exit code was
non-zero. The rest (--stop-on-defect, --stop-on-error, --stop-on-risky,
--stop-on-incomplete, --stop-on-warning, --stop-on-notice,
--stop-on-deprecation, --stop-on-skipped) were silently ignored.
WrapperRunner now precomputes the set of progress-file characters that
should trigger a stop (F, E, R, I, W, N, D, S) based on the configured
flags, and scans each worker's progress file for them after every
cycle. Once any matching outcome is seen, the pending queue is cleared.
Up to N-1 in-flight tests (where N is --processes) can still complete
after the first stop-worthy outcome — stopping them mid-run would risk
corrupting shared state.
Closes#1463.
* fix: preserve parallel stop conditions on Pest 5
* test: expand parallel stop-on regression coverage
* fix(tia): fingerprint the configuration file the run uses
* fix(tia): tell --no-configuration and identical copies of the configuration apart
* test(tia): cover the gitignore check with composer.lock, as the active configuration is fingerprinted tracked or not
* fix(tia): parse SFC entries when building the JS module graph
rolldown has no SFC handling, so every .vue/.svelte page failed to parse at the
first byte of <script> and the JS graph came back empty. Reduce the component to
its script blocks before rolldown sees it, which is enough for import specifiers.
Closes#1918
* fix(tia): keep template-only TS imports and stub CSS as JS
TypeScript elision dropped imports used only in a <template>, so lang="ts" pages lost those edges. Newer rolldown also rejects asset stubs without an explicit moduleType, failing the build on any CSS import.
* fix(tia): ignore comments when detecting default export
* Refresh SFC module graph regression snapshots
---------
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
* feat(tia): make default watch fallbacks configurable
* test(tia): cover driverless fallback and update suite snapshots
* fix: align help types and coverage guards with PHPStan
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): link files a test reads as text, not only files it executes
* fix(tia): report dangling symlinks as links while reads are captured
`is_link()` stats with STREAM_URL_STAT_LINK | STREAM_URL_STAT_QUIET.
The `file_exists()` precheck in `ReadCapture::url_stat()` follows the
link, so a dangling symlink returned false before reaching `lstat()`,
and `is_link()` reported false while a test recorded.
Handle STREAM_URL_STAT_LINK first and always answer it through
`lstat()`. A quiet stat of a path that is neither a link nor a file
still returns false without a warning.
The regression test covers a link to an existing file and a dangling
link.
* test(tia): skip the read-capture feature tests without a coverage driver
The fixture runs record a graph from coverage, so with CI's
`coverage: none` all five cases failed. Skip them when
`Coverage::isAvailable()` is false, as CoveragePiggyback does.
* chore: style
* Refresh read capture test snapshots
---------
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: check each target in negated toUse
A skipped class in expect([...]) made the positive rule fail,
so the negation passed even when another class used the dependency.
Fixes#1751
* test: update snapshots for notToUse
Negated toUse coverage adds 6 tests and 24 assertions,
so the success snapshot and parallel totals were stale.
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: run `pest()->afterAll()` hooks by flushing statics after `tearDownAfterClass()`
Fixes#1694
Testable::tearDown()'s finally block flushed the afterAll static after
every test via TestCaseMethodFactory::tearDown(), so by the time PHPUnit
called tearDownAfterClass() (which runs after the last test's tearDown())
the hook had already been nulled out. The per-test flush was redundant:
TestCaseMethodFactory::setUp() already flushes statics before re-applying
proxies for the next test. Move the flush into tearDownAfterClass()'s
finally block instead, so it happens after the hook actually runs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test: assert `afterAll` hooks run via isolated fixture suite
Runs a fixture suite in a subprocess and asserts both the
`pest()->afterAll()` and file-level `afterAll()` hooks ran once,
in order. Fails on unpatched 5.x (only `afterAll` is recorded).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* style: remove comment from afterAll hook test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fix afterAll test style and refresh snapshots
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
The GitLab baseline lookup listed the project's 100 most recent
successful jobs and filtered them client-side by name and ref. GitLab's
jobs endpoint has no server-side ref or name filter, so that single page
is the entire search space -- and on a busy project it covers very little
wall-clock time. On a self-hosted instance the window measured 82
minutes, while baselines were published roughly once a day. The lookup
therefore returned null almost always, and every developer silently fell
back to recording a local baseline.
Query pipelines instead, which does filter by ref and status server-side,
then walk the default branch's successful pipelines newest-first until
one contains a successful job with the configured name.
This also aligns the lookup with what the download actually resolves.
`glab job artifact <ref> <job>` reads from the latest successful
*pipeline* for the ref, so a successful job inside a failed pipeline was
never downloadable even when the old lookup returned it.
* fix(tia): show git's error instead of asking to install git when it fails
* fix(tia): detect a missing git binary with ExecutableFinder
Only report MissingDependency when git can't be found on PATH or there
is no repository. Any other failure shows git's error output, or the
exit code when git printed nothing.
---------
Co-authored-by: Mohannad Elemary <20709195+MohannadElemary@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
* fix(tia): detect renames in both porcelain status columns
git status --porcelain emits worktree renames as " R new\0old". The parser only checked the first status column, so the paired source path was read as a standalone record and truncated by substr(3). The broken path then made git check-ignore exit 128, which surfaced as MissingDependency("Tia mode", "git").
* Fix worktree rename test style
---------
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(sharding): strip `--runner` from the `--list-tests` sub-process
* fix(sharding): strip a space-separated `--runner` value too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test: count the two new shard tests in the visual suite totals
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Apa <mikko@apaiko.fi>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test: cover parallel group-filtered runs whose workers end on fully filtered files
A worker's serialized TestResult only carries the `numberOfTests` of the
last file it executed. When that file has all of its tests excluded by
`--group`/`--exclude-group`, the merged result used to claim the suite was
empty and the run exited 1 despite a green summary (PHPUnit enables
`failOnEmptyTestSuite` implicitly for explicit test selections).
942d6aea fixed this in `WrapperRunner::numberOfTestsSeenByWorker()`; these
tests pin the behaviour:
- with `--processes=1` the single worker deterministically ends on
ZTest.php, whose only test is outside the filtered group, so the run
must exit 0 (fails when the fix is reverted)
- a selection that matches no tests at all must still exit non-zero
Refs #1483
* test: assert the empty-selection message and update the success snapshot
The empty-selection case now also expects `No tests found.` and exit code 1,
so it no longer passes when the run fails for an unrelated reason.
`tests/.snapshots/success.txt` gains the two new tests of
`tests/Visual/Parallel.php`.
* Add default failure messages to the remaining string expectations
* test: update parallel snapshot count for the new default-message cases
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: accept `--no-results` and the `--do-not-*` test run history options with `--parallel`
* Update success snapshot count
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
* fix(tia): drop the coverage cache on structural drift
A coverage run cannot rebuild the graph, so a composer.lock change left the previous coverage.bin.gz in place and the next merge failed.
* style(tests): satisfy rector dry-run
* style: remove the source comment
Repository instructions prohibit source comments.
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
* fix(tia): write the merged coverage report in chunks
var_export() of the serialized coverage held a second escaped copy of the payload and exhausted memory after a large suite.
* test: count the chunked coverage report in visual snapshots
The two CoverageReport tests add two passes and four assertions to the suite totals.
* test: separate coverage report files in the success snapshot
Pest prints a blank line between files, so the snapshot was not a substring of the suite output.
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): drop cached coverage of tests that no longer exist
A deleted or renamed test never runs again, so its hits stayed in
coverage.bin.gz and --min passed on a real coverage drop.
Fixes#1957
* Update deleted coverage success snapshot
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): keep pcov.enabled when the pcov restarter re-runs pest
* test: cover pcov.enabled in the pcov restarter command
---------
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>