mirror of
https://github.com/pestphp/pest.git
synced 2026-07-24 02:20:03 +02:00
fix: tia
This commit is contained in:
+7
-2
@@ -562,7 +562,7 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
$this->snapshotTestResults();
|
||||
$this->snapshotTestResults(markKnownTestFiles: true);
|
||||
|
||||
return $exitCode;
|
||||
}
|
||||
@@ -1394,12 +1394,13 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
);
|
||||
}
|
||||
|
||||
$graph->markKnownTestFiles(array_keys($touchedFiles));
|
||||
$graph->pruneStaleResults($this->branch, array_keys($touchedFiles), array_keys($results));
|
||||
|
||||
$collector->reset();
|
||||
}
|
||||
|
||||
private function snapshotTestResults(): void
|
||||
private function snapshotTestResults(bool $markKnownTestFiles = false): void
|
||||
{
|
||||
/** @var ResultCollector $collector */
|
||||
$collector = Container::getInstance()->get(ResultCollector::class);
|
||||
@@ -1442,6 +1443,10 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
||||
);
|
||||
}
|
||||
|
||||
if ($markKnownTestFiles) {
|
||||
$graph->markKnownTestFiles(array_keys($touchedFiles));
|
||||
}
|
||||
|
||||
$graph->pruneStaleResults($this->branch, array_keys($touchedFiles), array_keys($results));
|
||||
|
||||
$this->saveGraph($graph);
|
||||
|
||||
@@ -813,6 +813,38 @@ final class Graph
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark test files that executed under a recorded coverage session as "known",
|
||||
* seeding an empty edge set for any that produced zero project-source edges.
|
||||
*
|
||||
* Without this, a test that covers no application source (e.g. a pure unit
|
||||
* test asserting on language primitives) never becomes an edge key, so
|
||||
* {@see self::knowsTest()} reports it as unknown and it re-runs on every TIA
|
||||
* run. Recording it with an empty edge set lets it be replayed/skipped while
|
||||
* unchanged; it is still re-run whenever its own file changes, via
|
||||
* {@see self::applyTestFileChanges()}.
|
||||
*
|
||||
* Must only be called from the recording path, where coverage was actually
|
||||
* collected — otherwise a missing edge set could mean "coverage was off",
|
||||
* not "genuinely covered nothing".
|
||||
*
|
||||
* @param array<int, string> $testFiles Absolute or project-relative test file paths.
|
||||
*/
|
||||
public function markKnownTestFiles(array $testFiles): void
|
||||
{
|
||||
foreach ($testFiles as $testFile) {
|
||||
$rel = $this->relative($testFile);
|
||||
|
||||
if ($rel === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($this->edges[$rel])) {
|
||||
$this->edges[$rel] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, array<int, string>> $testToTables
|
||||
*/
|
||||
|
||||
@@ -45,9 +45,7 @@ final readonly class TestPaths
|
||||
$directories[] = $rel;
|
||||
}
|
||||
|
||||
$suffix = $directory->suffix();
|
||||
|
||||
$suffixes[] = str_starts_with($suffix, '.') ? $suffix : '.'.$suffix;
|
||||
$suffixes[] = $directory->suffix();
|
||||
}
|
||||
|
||||
foreach ($suite->files() as $file) {
|
||||
@@ -61,7 +59,7 @@ final readonly class TestPaths
|
||||
|
||||
if ($suffixes === []) {
|
||||
foreach ($configuration->testSuffixes() as $suffix) {
|
||||
$suffixes[] = str_starts_with($suffix, '.') ? $suffix : '.'.$suffix;
|
||||
$suffixes[] = $suffix;
|
||||
}
|
||||
}
|
||||
} catch (Throwable) {
|
||||
|
||||
Reference in New Issue
Block a user