From 37bdf60a1cd29b31e1266e06acaac90741498a37 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Fri, 7 Aug 2026 01:41:32 +0100 Subject: [PATCH] wip --- src/Plugins/Tia.php | 8 +----- src/Plugins/Tia/Graph.php | 12 +++++--- tests/.snapshots/success.txt | 41 ++++++++++++++++++++++++++- tests/Features/Tia/BranchShapes.php | 4 +-- tests/Features/Tia/RemoteBaseline.php | 2 +- tests/Fixtures/Tia/Project.php | 2 +- 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/Plugins/Tia.php b/src/Plugins/Tia.php index b43a76d9..1cbdac95 100644 --- a/src/Plugins/Tia.php +++ b/src/Plugins/Tia.php @@ -2085,13 +2085,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument } } - foreach ($testPaths as $testPath) { - if (str_starts_with($testPath, $candidate.DIRECTORY_SEPARATOR)) { - return false; - } - } - - return true; + return array_all($testPaths, fn (string $testPath): bool => ! str_starts_with($testPath, $candidate.DIRECTORY_SEPARATOR)); } private function resolveArgumentPath(string $arg, string $projectRoot): ?string diff --git a/src/Plugins/Tia/Graph.php b/src/Plugins/Tia/Graph.php index bf2c2da5..414e5ef0 100644 --- a/src/Plugins/Tia/Graph.php +++ b/src/Plugins/Tia/Graph.php @@ -1541,14 +1541,18 @@ final class Graph foreach ($this->baselines[$branch]['results'] as $testId => $result) { $file = $result['file'] ?? null; - - if (! is_string($file) || $file === '') { + if (! is_string($file)) { + continue; + } + if ($file === '') { continue; } $rel = $this->relative($file); - - if ($rel === null || is_file($root.$rel)) { + if ($rel === null) { + continue; + } + if (is_file($root.$rel)) { continue; } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index e20e6023..7b94de6b 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1583,6 +1583,10 @@ ✓ a narrowed run does not reclaim anything ✓ a detached HEAD does not reclaim anything either ✓ the default branch baseline survives every branch that comes and goes + ✓ a project below the git repository root refuses to run and writes nothing with dataset "sequential" + ✓ a project below the git repository root refuses to run and writes nothing with dataset "parallel" + ✓ a repository with no commits says so, and leaves plain runs alone + ✓ a directory with no repository at all still asks for git PASS Tests\Features\Tia\CompleteRunWriteTier ✓ a complete run prunes a deleted test with dataset "sequential" @@ -1603,6 +1607,13 @@ ✓ a test edit narrows to the affected file and replays the rest ✓ a parallel run merges worker results into the parent baseline + PASS Tests\Features\Tia\CoveragePiggyback + ✓ a coverage report does not found a dependency graph with dataset "pest coverage" + ✓ a coverage report does not found a dependency graph with dataset "phpunit coverage report" + ✓ a coverage report does not found a dependency graph with dataset "parallel" + ✓ a plain run after a coverage run records the whole project scope + ✓ a coverage report leaves the edges of an existing graph alone + PASS Tests\Features\Tia\DefaultBranchReplay ✓ replays the default branch baseline on a new branch ✓ replays whatever the default branch is called with ('main') @@ -1710,6 +1721,32 @@ ✓ a shard is a partial run ✓ a parallel partial run records the test that ran, like a sequential one + PASS Tests\Features\Tia\RemoteBaseline + ✓ a published baseline is fetched instead of recorded locally + ✓ a fetched baseline that will not decode is discarded rather than trusted + ✓ a fetched baseline recorded against another tree is not used + ✓ an artifact without a graph in it fails loudly + ✓ a baseline that cannot be authenticated for fails loudly + ✓ a workflow or artifact that is not there fails loudly + ✓ a network failure warns and lets the suite run with dataset "querying the runs" + ✓ a network failure warns and lets the suite run with dataset "downloading the artifact" + ✓ no published baseline yet starts a cooldown, and a corrupt cooldown does not break the run + + PASS Tests\Features\Tia\SelectionPaths + ✓ a committed rename selects the tests that depended on the old path with dataset "sequential" + ✓ a committed rename selects the tests that depended on the old path with dataset "parallel" + ✓ an affected test file that is gone does not strand a filtered run with dataset "sequential" + ✓ an affected test file that is gone does not strand a filtered run with dataset "parallel" + ✓ a plain run reclaims the edge of a test file that is gone + ✓ a changed view selects the test that rendered it + ✓ a changed partial selects the test that rendered its ancestor with dataset "direct @include" + ✓ a changed partial selects the test that rendered its ancestor with dataset "transitive @include" + ✓ a changed partial selects the test that rendered its ancestor with dataset "x- component" + ✓ a changed partial selects the test that rendered its ancestor with dataset "include cycle" + ✓ a changed Inertia page selects the test that rendered its component + ✓ a changed shared JS module selects the tests of the pages that import it + ✓ a changed frontend runtime file selects every Inertia test + PASS Tests\Features\Tia\StateReclamation ✓ a detached HEAD does not purge the graph on structural drift with dataset "sequential" ✓ a detached HEAD does not purge the graph on structural drift with dataset "parallel" @@ -1748,6 +1785,8 @@ ✓ --fresh on a partial run neither purges nor prunes with dataset "parallel" ✓ a second green run on a feature branch writes nothing at all with dataset "sequential" ✓ a second green run on a feature branch writes nothing at all with dataset "parallel" + ✓ a graph whose recorded commit is gone is re-anchored, not warned about forever with dataset "sequential" + ✓ a graph whose recorded commit is gone is re-anchored, not warned about forever with dataset "parallel" PASS Tests\Features\Ticket ✓ it may be associated with an ticket #1, #2 @@ -2378,4 +2417,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1710 passed (3845 assertions) \ No newline at end of file + Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1743 passed (3953 assertions) \ No newline at end of file diff --git a/tests/Features/Tia/BranchShapes.php b/tests/Features/Tia/BranchShapes.php index d608cc8b..a7a5f1e0 100644 --- a/tests/Features/Tia/BranchShapes.php +++ b/tests/Features/Tia/BranchShapes.php @@ -170,8 +170,8 @@ test('a project below the git repository root refuses to run and writes nothing' expect($result->exitCode)->toBe(1, $result->describe()) ->and($result->output)->toContain('Tia mode requires the git repository root') - ->and(is_dir($project->path('.home/.pest')))->toBeFalse() - ->and(is_dir($nested.DIRECTORY_SEPARATOR.'.pest'))->toBeFalse(); + ->and($project->path('.home/.pest'))->not->toBeDirectory() + ->and($nested.DIRECTORY_SEPARATOR.'.pest')->not->toBeDirectory(); })->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows(); test('a repository with no commits says so, and leaves plain runs alone', function (): void { diff --git a/tests/Features/Tia/RemoteBaseline.php b/tests/Features/Tia/RemoteBaseline.php index 49a4a06c..dfc809db 100644 --- a/tests/Features/Tia/RemoteBaseline.php +++ b/tests/Features/Tia/RemoteBaseline.php @@ -133,7 +133,7 @@ test('no published baseline yet starts a cooldown, and a corrupt cooldown does n expect($first->exitCode)->toBe(0, $first->describe()) ->and($first->output)->toContain('No baseline published yet') - ->and(is_file($project->graphDir().DIRECTORY_SEPARATOR.'fetch-cooldown.json'))->toBeTrue(); + ->and($project->graphDir().DIRECTORY_SEPARATOR.'fetch-cooldown.json')->toBeFile(); $discardGraph(); diff --git a/tests/Fixtures/Tia/Project.php b/tests/Fixtures/Tia/Project.php index 73cbabc8..74506a99 100644 --- a/tests/Fixtures/Tia/Project.php +++ b/tests/Fixtures/Tia/Project.php @@ -301,7 +301,7 @@ final class Project $this->write('payload/graph.json', $payload); return [ - 'PATH' => $this->path('stub').PATH_SEPARATOR.(string) getenv('PATH'), + 'PATH' => $this->path('stub').PATH_SEPARATOR.getenv('PATH'), 'GH_STUB_MODE' => $mode, 'GH_STUB_PAYLOAD' => $this->path('payload/graph.json'), ];