From 1f412756df105fdb8452582468e6a827a7066792 Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Fri, 14 Aug 2026 05:18:45 +0500 Subject: [PATCH] fix(tia): re-anchor after a full suite run without a coverage driver --- src/Plugins/Tia.php | 6 +++++- tests/Features/Tia/StateReclamation.php | 27 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Tia.php b/src/Plugins/Tia.php index ff1f5b066..dda0f52de 100644 --- a/src/Plugins/Tia.php +++ b/src/Plugins/Tia.php @@ -200,6 +200,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument private bool $graphUnreachable = false; + private bool $fullSuiteFallbackRan = false; + /** @var array */ private array $originalArguments = []; @@ -684,7 +686,7 @@ public function addOutput(int $exitCode): int return $exitCode; } - if ($this->replayRan || $this->graphUnreachable) { + if ($this->replayRan || $this->graphUnreachable || $this->fullSuiteFallbackRan) { $this->bumpRecordedSha(); } @@ -1044,6 +1046,8 @@ private function enterReplayMode(Graph $graph, string $projectRoot, array $argum $coverageAvailable = $this->piggybackCoverage || $this->recorder->driverAvailable(); if ($hasProjectPhpSourceChanges && ! $coverageAvailable) { + $this->fullSuiteFallbackRan = true; + $this->renderBadge('WARN', 'Detected PHP source changes but no coverage driver is available.'); $this->renderChild('Running the full suite to avoid using a stale dependency graph.'); $this->renderChild('Install / enable pcov or xdebug (mode: coverage) so edges can be safely refreshed after PHP refactors.'); diff --git a/tests/Features/Tia/StateReclamation.php b/tests/Features/Tia/StateReclamation.php index c5c625bd2..e43b82173 100644 --- a/tests/Features/Tia/StateReclamation.php +++ b/tests/Features/Tia/StateReclamation.php @@ -358,3 +358,30 @@ ->and($second->replayed())->toBe(Project::TOTAL_TESTS, $second->describe()) ->and($delta->writtenCount())->toBe(0, $delta->summary()); })->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows(); + +test('a full suite run without a coverage driver clears the tree it could not refresh', function (array $arguments): void { + $project = Project::make('master'); + $project->seed('master'); + + $project->mutateGraph(function (array $graph): array { + $graph['baselines']['master']['tree'] = ['app/Calculator.php' => 'deadbeefdeadbeefdeadbeefdeadbeef']; + + return $graph; + }); + + $environment = ['XDEBUG_MODE' => 'off']; + + $first = $project->pestWithEnvironment($project->path(), $environment, '--tia', ...$arguments); + + expect($first->exitCode)->toBe(0, $first->describe()) + ->and($first->output)->toContain('no coverage driver is available') + ->and($first->tally())->toContain(Project::TOTAL_TESTS.' passed'); + + $project->snapshot(); + $second = $project->pestWithEnvironment($project->path(), $environment, '--tia', ...$arguments); + $delta = $project->delta(); + + expect($second->output)->not->toContain('no coverage driver is available') + ->and($second->replayed())->toBe(Project::TOTAL_TESTS, $second->describe()) + ->and($delta->writtenCount())->toBe(0, $delta->summary()); +})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();