Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Plugins/Tia.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument

private bool $graphUnreachable = false;

private bool $fullSuiteFallbackRan = false;

/** @var array<int, string> */
private array $originalArguments = [];

Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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.');
Expand Down
27 changes: 27 additions & 0 deletions tests/Features/Tia/StateReclamation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();