find('git'); assert(is_string($git)); $directory = $project->path('.fake-git'); $realGit = escapeshellarg($git); mkdir($directory); file_put_contents($directory.'/git', <<path('.git/info'))) { mkdir($project->path('.git/info')); } file_put_contents($project->path('.git/info/exclude'), "/.fake-git/\n", FILE_APPEND); return $directory.PATH_SEPARATOR.getenv('PATH'); } test('a slow git while naming the branch records nothing without --tia', function (): void { $project = Project::make('master'); $project->seed('master'); $path = fakeGitPath($project, '"symbolic-ref "*) exec sleep 6 ;;'); $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path]); $delta = $project->delta(); expect($result->exitCode)->toBe(0, $result->describe()) ->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed') ->and($result->output)->not->toContain('Git did not answer') ->and($delta->baselineUntouched('master'))->toBeTrue($delta->summary()); })->skipOnWindows(); test('a slow branch listing after the suite keeps the run results without --tia', function (): void { $project = Project::make('master'); $project->seed('master'); $path = fakeGitPath($project, '"for-each-ref "*) exec sleep 6 ;;'); $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path]); $delta = $project->delta(); expect($result->exitCode)->toBe(0, $result->describe()) ->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed') ->and($result->output)->not->toContain('Git did not answer') ->and($project->branchKeys())->toBe(['master']) ->and($delta->writtenCount())->toBe(Project::TOTAL_TESTS, $delta->summary()); })->skipOnWindows(); test('a run without --tia records nothing when git cannot name the current branch', function (): void { $project = Project::make('master'); $project->seed('master'); $path = fakeGitPath($project, '"rev-parse --abbrev-ref") exit 128 ;;'); $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path]); $delta = $project->delta(); expect($result->exitCode)->toBe(0, $result->describe()) ->and($result->tally())->toContain(Project::TOTAL_TESTS.' passed') ->and($project->branchKeys())->toBe(['master']) ->and($delta->baselineUntouched('master'))->toBeTrue($delta->summary()); })->skipOnWindows(); test('a slow git stops a --tia run with the timeout', function (): void { $project = Project::make('master'); $project->seed('master'); $path = fakeGitPath($project, '"symbolic-ref "*) exec sleep 6 ;;'); $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path], '--tia'); expect($result->exitCode)->toBe(1, $result->describe()) ->and($result->output)->toContain('Git did not answer within 5 seconds: git symbolic-ref') ->and($result->output)->not->toContain('default branch'); })->skipOnWindows(); test('a slow git check-ignore keeps composer.lock in the fingerprint', function (): void { $project = Project::make('master'); $project->seed('master'); $path = fakeGitPath($project, '"check-ignore -z") exec sleep 6 ;;'); $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path], '--tia'); $delta = $project->delta(); expect($result->exitCode)->toBe(0, $result->describe()) ->and($result->output)->not->toContain('Git did not answer') ->and($result->replayed())->toBe(Project::TOTAL_TESTS, $result->describe()) ->and($delta->structureMoved())->toBeFalse($delta->summary()); })->skipOnWindows(); test('a slow git stops a --tia run with the command that timed out first', function (): void { $project = Project::make('master'); $project->seed('master'); $path = fakeGitPath($project, '"symbolic-ref "*|"rev-parse --git-dir") exec sleep 6 ;;'); $result = $project->pestWithEnvironment($project->path(), ['PATH' => $path], '--tia'); expect($result->exitCode)->toBe(1, $result->describe()) ->and($result->output)->toContain('Git did not answer within 5 seconds: git symbolic-ref'); })->skipOnWindows();