From 586add8ff2b050d898b40d9fd5a60c4f448bb5c2 Mon Sep 17 00:00:00 2001 From: Jhon Farias Date: Fri, 4 Dec 2026 09:31:13 +0100 Subject: [PATCH] fix(tia): keep the run going when git is slow at boot (#2088) * fix(tia): keep the run going when git is slow at boot * fix(tia): catch GitTimedOut in the boot git calls Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- src/Plugins/Tia/Storage.php | 13 ++++++- tests/Features/Tia/SlowGitAtBoot.php | 57 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 tests/Features/Tia/SlowGitAtBoot.php diff --git a/src/Plugins/Tia/Storage.php b/src/Plugins/Tia/Storage.php index 7bdc635c..6b355b23 100644 --- a/src/Plugins/Tia/Storage.php +++ b/src/Plugins/Tia/Storage.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Pest\Plugins\Tia; +use Pest\Exceptions\GitTimedOut; use Pest\Support\Git; /** @@ -134,12 +135,20 @@ final class Storage private static function rawOriginUrl(string $projectRoot): ?string { - return new Git($projectRoot)->originUrl(); + try { + return new Git($projectRoot)->originUrl(); + } catch (GitTimedOut) { + return null; + } } private static function gitPrefix(string $projectRoot): string { - return new Git($projectRoot)->pathPrefix(); + try { + return new Git($projectRoot)->pathPrefix(); + } catch (GitTimedOut) { + return ''; + } } private static function slug(string $name): string diff --git a/tests/Features/Tia/SlowGitAtBoot.php b/tests/Features/Tia/SlowGitAtBoot.php new file mode 100644 index 00000000..afe236ab --- /dev/null +++ b/tests/Features/Tia/SlowGitAtBoot.php @@ -0,0 +1,57 @@ +find('git'); + + assert(is_string($git)); + + $directory = $project->path('.slow-git'); + $realGit = escapeshellarg($git); + $slept = escapeshellarg($directory.'/slept'); + + mkdir($directory); + file_put_contents($directory.'/git', <<seed('master'); + + $path = slowGitAtBootPath($project, 'config --get'); + $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path]); + + expect($result->exitCode)->toBe(0, $result->describe()) + ->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed') + ->and($project->path('.slow-git/slept'))->toBeFile('the slow git never ran'); +})->skipOnWindows(); + +test('a slow git while reading the path prefix does not stop a run without --tia', function (): void { + $project = Project::make('master'); + $project->seed('master'); + + $path = slowGitAtBootPath($project, 'rev-parse --show-prefix'); + $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path]); + + expect($result->exitCode)->toBe(0, $result->describe()) + ->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed') + ->and($project->path('.slow-git/slept'))->toBeFile('the slow git never ran'); +})->skipOnWindows();