Match deleted paths against TIA watch patterns (#2050)

Co-authored-by: haranishi <223786623+haranishi@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
Ikki Nishihara
2026-11-20 05:32:20 +09:00
committed by GitHub
parent 9990d0ee36
commit 4a66e6888d
2 changed files with 29 additions and 7 deletions
+1 -7
View File
@@ -655,13 +655,7 @@ final class Graph
if (isset($handledBlade[$rel])) {
continue;
}
if (! isset($this->fileIds[$rel])) {
if (! is_file($this->projectRoot.'/'.$rel)) {
continue;
}
$watchedPaths[] = $rel;
} elseif ($this->isFrameworkBootPath($rel)) {
if (! isset($this->fileIds[$rel]) || $this->isFrameworkBootPath($rel)) {
$watchedPaths[] = $rel;
}
}
+28
View File
@@ -63,3 +63,31 @@ test('still runs every test without a baseline when defaults are disabled', func
expect($result->exitCode)->toBe(0, $result->describe())
->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed');
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
test('runs dependent tests when a watched path is removed', function (array $gitArguments, array $arguments): void {
$project = Project::make('master');
$project->write('schema/api.graphql', "type Query { status: String }\n");
$project->write('tests/Pest.php', file_get_contents($project->path('tests/Pest.php')).
"\npest()->tia()->withoutDefaultWatchPatterns()->watch(['schema/*.graphql' => 'tests/Unit/GreeterTest.php']);\n");
$test = 'tests/Unit/GreeterTest.php';
$project->write($test, str_replace(
"test('greets a person', function (): void {",
"test('greets a person', function (): void {\n expect('schema/api.graphql')->toBeFile();",
file_get_contents($project->path($test)),
));
$project->git()->commit('add a watched schema and its test');
$project->seed('master');
$project->git()->run($gitArguments);
$project->git()->commit('remove the watched path');
$result = $project->pest('--tia', '--filtered', ...$arguments);
expect($result->exitCode)->toBe(1, $result->describe())
->and($result->affected())->toBe(2, $result->describe())
->and($result->output)->toContain('greets a person', 'schema/api.graphql');
})->with([
'deleted' => [['rm', '--', 'schema/api.graphql']],
'renamed' => [['mv', '--', 'schema/api.graphql', 'moved.graphql']],
])->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();