Allow help and version before the test suite is initialized (#2051)

Co-authored-by: haranishi <223786623+haranishi@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Ikki Nishihara
2026-11-20 18:50:17 +09:00
committed by GitHub
parent f80b3a89a0
commit 67d3733eb2
4 changed files with 31 additions and 9 deletions
+7 -3
View File
@@ -36,7 +36,7 @@ final class BootFiles implements Bootstrapper
public function boot(): void
{
if ($this->runningInit()) {
if ($this->hasCliOption('--init')) {
return;
}
@@ -44,6 +44,10 @@ final class BootFiles implements Bootstrapper
$testsPath = $rootPath.DIRECTORY_SEPARATOR.testDirectory();
if (! is_dir($testsPath)) {
if ($this->hasCliOption('--help', '--version')) {
return;
}
throw new FatalException(sprintf('The test directory [%s] does not exist.', $testsPath));
}
@@ -69,7 +73,7 @@ final class BootFiles implements Bootstrapper
$this->bootDatasets($testsPath);
}
private function runningInit(): bool
private function hasCliOption(string ...$options): bool
{
$arguments = $_SERVER['argv'] ?? null;
@@ -78,7 +82,7 @@ final class BootFiles implements Bootstrapper
}
/** @var array<int, string> $arguments */
return $this->hasArgument('--init', $arguments);
return array_any($options, fn (string $option): bool => $this->hasArgument($option, $arguments));
}
private function load(string $filename): void