mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 06:13:35 +02:00
fix(tia): re-anchor after a full suite run without a coverage driver (#1866)
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
eac05bcee9
commit
20a5aacaca
+5
-1
@@ -200,6 +200,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
|||||||
|
|
||||||
private bool $graphUnreachable = false;
|
private bool $graphUnreachable = false;
|
||||||
|
|
||||||
|
private bool $fullSuiteFallbackRan = false;
|
||||||
|
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
private array $originalArguments = [];
|
private array $originalArguments = [];
|
||||||
|
|
||||||
@@ -684,7 +686,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
|||||||
return $exitCode;
|
return $exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->replayRan || $this->graphUnreachable) {
|
if ($this->replayRan || $this->graphUnreachable || $this->fullSuiteFallbackRan) {
|
||||||
$this->bumpRecordedSha();
|
$this->bumpRecordedSha();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1044,6 +1046,8 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
|||||||
$coverageAvailable = $this->piggybackCoverage || $this->recorder->driverAvailable();
|
$coverageAvailable = $this->piggybackCoverage || $this->recorder->driverAvailable();
|
||||||
|
|
||||||
if ($hasProjectPhpSourceChanges && ! $coverageAvailable) {
|
if ($hasProjectPhpSourceChanges && ! $coverageAvailable) {
|
||||||
|
$this->fullSuiteFallbackRan = true;
|
||||||
|
|
||||||
$this->renderBadge('WARN', 'Detected PHP source changes but no coverage driver is available.');
|
$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('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.');
|
$this->renderChild('Install / enable pcov or xdebug (mode: coverage) so edges can be safely refreshed after PHP refactors.');
|
||||||
|
|||||||
@@ -358,3 +358,30 @@ test('a graph whose recorded commit is gone is re-anchored, not warned about for
|
|||||||
->and($second->replayed())->toBe(Project::TOTAL_TESTS, $second->describe())
|
->and($second->replayed())->toBe(Project::TOTAL_TESTS, $second->describe())
|
||||||
->and($delta->writtenCount())->toBe(0, $delta->summary());
|
->and($delta->writtenCount())->toBe(0, $delta->summary());
|
||||||
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
})->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();
|
||||||
|
|||||||
Reference in New Issue
Block a user