* fix(tia): skip locally() when the process is on CI
locally() only looked at --ci, so a CI job that followed the docs and
ran plain pest replayed cached results.
Fixes#1970
* test(tia): clear CI variables so the local assertion passes on CI
* test: update snapshots for TIA CI detection
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix(tia): drop coverage lines the current file no longer has
An edited file left the previous line numbers in the cache as uncovered,
and a revert did not remove them.
Fixes#1954
* test: update snapshots for skipped stale coverage regression
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
`Backtrace::backtrace()` skipped a frame when its path held `pest/src`, so
a checkout of this repository in a directory with any other name, such as
`pest5`, returned `src/Support/Backtrace.php` as the file of the caller and
`tests/Unit/Support/Backtrace.php` failed. The frame check now compares
against the directory that holds this file, which is the same directory
whether Pest runs from its own checkout or from `vendor/pestphp/pest`, and
the global that marked the internal test suite has no reader left.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
A fetched baseline can be recorded at a commit that the local clone does not have, or that the current branch does not contain. The changed files cannot be listed then, and the replay treated the changed set as empty: every test was replayed as passed.
Stop with an error that names the commit and says how to recover.
`GitHubRemote::artifactSize()` passes `select(.name === "…")` to
`gh api --jq`. jq has no `===` operator: gh's embedded jq rejects the
filter ("unexpected token"), so the lookup always fails and the baseline
download never shows its size.
The filter used `==` while it lived in `BaselineSync`, which the strict
arch preset ignores. #1841 moved it into `GitHubRemote`, where the preset
flags the `==` inside the jq string. Restore `==` and ignore
`GitHubRemote` in the strict preset, as `BaselineSync` already is.
* fix: allow --init without a tests directory
Boot aborted before TIA state was registered, and shutdown then
tried to construct the plugin. That hid the real error behind
"State cannot be resolved" on a fresh install.
Closes#1934
* fix: detect --init anywhere in the arguments
Flags before --init were still treated as a normal run and failed when tests/ did not exist.
* fix: drop duplicate Kernel::$booted and share --init check
5.3.1 already gates plugin termination on boot, so the rebase must
not declare $booted again. --init and --init=value now share
HandleArguments::hasArgument, and the success snapshot includes
the new init tests.
* test: fix init suite expectations
Parallel total omitted the four --init tests, which
failed the success snapshot. Rector requires toBeFile().
---------
Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
* test(shard): cover module test classes outside the tests directory
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* chore: refresh the snapshot counts
---------
Co-authored-by: Paul Sochiera <paul.sochiera@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
* fix: avoid passing an object when invoking static methods via reflection
PHP 8.6 deprecates passing an object to `ReflectionMethod::invoke()` for
static methods, which breaks higher-order assertions such as
`it('...')->assertTrue(true)` since `Assert::assertTrue()` is static.
* test: update visual snapshots for new reflection tests
* fix: support brianium/paratest 7.26.1 worker tmp dir
paratest 7.26.1 added a required $tmpDir argument to WrapperWorker and
keeps worker files in a private per-run directory. Create that 0700
directory per run, pass it to each worker and remove it on completion.
Require paratest ^7.26.1.
* ci: bump shivammathur/setup-php to 2.40.0 for PHP 8.5 on macos-latest
---------
Co-authored-by: ExeQue <mmh@harders-it.dk>
paratest 7.26.1 added a required $tmpDir argument to WrapperWorker and
keeps worker files in a private per-run directory. Create that 0700
directory per run, pass it to each worker and remove it on completion.
Require paratest ^7.26.1.
* refactor: extract shared CI detection utility
Consolidate duplicated CI environment detection logic from
Snapshot and BaselineSync into a shared Pest\Support\Ci class.
This reduces duplication and provides a single source of truth
for CI detection, including comprehensive environment variable
checks for all major CI providers.
* fix(tia): persist state on detached HEAD
Allow detached checkouts to write, delete, and rebuild TIA state so
baseline publishers and local detached workflows produce a usable graph.
Resolve the writable baseline from the Git branch, CI branch metadata, or
a stable workspace key. Keep the default branch as the read fallback so
local workspaces can use a published baseline without changing it.
Extract BaselineSync into a provider architecture with an abstract
BaseRemote class and concrete GitHubRemote/GitLabRemote implementations.
GitLab support uses the glab CLI to fetch TIA baselines from CI
pipelines. The GitLabRemote queries the GitLab API for the latest
successful job matching the configured name on the default branch,
then downloads artifacts via `glab job artifact`.
Self-hosted GitLab instances are supported automatically: any
non-GitHub remote is detected as GitLab when the glab CLI is
installed, with authentication validated at fetch time.
Key changes:
- BaseRemote abstract class holds shared logic: CLI existence/auth
checks, error classification, git remote URL parsing, and default
branch resolution
- GitHubRemote extracts existing gh CLI logic unchanged
- GitLabRemote adds glab CLI support with default job name
`tia-baseline`, configurable via `->baselined(job: "name")`
- BaselineSync becomes a provider-agnostic orchestrator that iterates
registered remotes to detect the matching CI provider
- Configuration::baselined() accepts optional `job` parameter for
GitLab job name customization
- GitLab job query filters by both job name and default branch ref
to ensure cache key matches downloaded artifact
* fix: key Tia worker partials per process to survive batch recycling
* test(tia): refresh visual snapshots for the worker token test
---------
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
When phpunit.xml has <coverage> and <source> sections, PHPUnit
auto-initializes its code coverage driver which takes over
xdebug's coverage APIs. TIA's recorder then gets empty data
from xdebug_get_code_coverage(), resulting in zero recorded
edges and no graph being saved.
Inject --no-coverage into the arguments when TIA enters its
own recording mode (not piggybacking on an explicit coverage
report). This tells PHPUnit to ignore XML-configured coverage
reports, leaving xdebug free for TIA's per-test recording.
Having <coverage> and <source> in phpunit.xml is standard for
any project that generates coverage reports. Without this fix,
users must manually pass --no-coverage alongside --tia, which
is an unnecessary footgun.