mirror of
https://github.com/pestphp/pest.git
synced 2026-12-05 15:22:17 +01:00
586add8ff2
* 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Symfony\Component\Process\ExecutableFinder;
|
|
use Tests\Fixtures\Tia\Project;
|
|
|
|
afterEach(function (): void {
|
|
Project::destroyAll();
|
|
});
|
|
|
|
function slowGitAtBootPath(Project $project, string $command): string
|
|
{
|
|
$git = (new ExecutableFinder)->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', <<<SH
|
|
#!/bin/sh
|
|
case "\$1 \$2" in
|
|
"{$command}") [ -e {$slept} ] || { touch {$slept}; exec sleep 6; } ;;
|
|
esac
|
|
exec {$realGit} "\$@"
|
|
SH);
|
|
chmod($directory.'/git', 0755);
|
|
|
|
return $directory.PATH_SEPARATOR.getenv('PATH');
|
|
}
|
|
|
|
test('a slow git while reading the origin url does not stop a run without --tia', function (): void {
|
|
$project = Project::make('master');
|
|
$project->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();
|