fix(tia): drop the results of every branch on environment drift (#2011)

Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Lazizbek Ergashev
2026-11-03 18:09:26 +05:00
committed by GitHub
parent ceef9806c2
commit 0224b4238b
5 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -835,7 +835,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
implode(', ', $drift),
));
$graph->clearResults($this->branch);
$graph->clearResults();
$graph->setFingerprint($current);
$this->saveGraph($graph);
$this->deleteState(self::KEY_COVERAGE_CACHE);
+4 -3
View File
@@ -943,10 +943,11 @@ final class Graph
$this->baselines[$branch]['tree'] = $tree;
}
public function clearResults(string $branch): void
public function clearResults(): void
{
$this->ensureBaseline($branch);
$this->baselines[$branch]['results'] = [];
foreach (array_keys($this->baselines) as $branch) {
$this->baselines[$branch]['results'] = [];
}
}
/**
+2 -1
View File
@@ -1943,6 +1943,7 @@
✓ markKnownTestFiles() → it makes a test file with no edges known
✓ markKnownTestFiles() → it does not clobber edges of an already-known test file
✓ markKnownTestFiles() → it ignores paths outside the project root
✓ clearResults() → it drops the results of the fallback branch too
PASS Tests\Unit\Plugins\Tia\IsEnabledForRun
✓ does not throw when an integer --random-order-seed is passed as a separate argv element
@@ -2293,4 +2294,4 @@
✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value')
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 36 skipped, 1625 passed (3589 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 36 skipped, 1626 passed (3592 assertions)
+14
View File
@@ -312,3 +312,17 @@ describe('markKnownTestFiles()', function (): void {
expect($graph->knowsTest('/somewhere/else/tests/FooTest.php'))->toBeFalse();
});
});
describe('clearResults()', function (): void {
it('drops the results of the fallback branch too', function (): void {
$graph = new Graph(sys_get_temp_dir());
$graph->setResult('main', 'Tests\FooTest::it passes', 0, '', 0.1, 1);
$graph->setResult('feature', 'Tests\BarTest::it passes', 0, '', 0.1, 1);
$graph->clearResults();
expect($graph->getResult('feature', 'Tests\FooTest::it passes'))->toBeNull()
->and($graph->getResult('feature', 'Tests\BarTest::it passes'))->toBeNull()
->and($graph->getResult('main', 'Tests\FooTest::it passes'))->toBeNull();
});
});
+1 -1
View File
@@ -20,7 +20,7 @@ test('parallel', function () use ($run): void {
$output = $run('--exclude-group=integration');
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 28 skipped, 1606 passed (3531 assertions)';
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 28 skipped, 1607 passed (3534 assertions)';
expect($output)
->toContain("Tests: {$expected}")