argumentsContainParallelFlags($arguments)) { $exitCode = $this->runTestSuiteInParallel($arguments); exit($exitCode); } $this->markTestSuiteAsParallelSubProcessIfRequired(); return $arguments; } private function argumentsContainParallelFlags(array $arguments): bool { return $this->hasArgument('--parallel', $arguments) || $this->hasArgument('-p', $arguments); } private function runTestSuiteInParallel(array $arguments): int { if (! class_exists(ParaTestCommand::class)) { $this->askUserToInstallParatest(); return 1; } $filteredArguments = array_reduce( $this->handlers, fn($arguments, $handler) => (new $handler())->handle($arguments), $arguments ); $testSuite = TestSuite::getInstance(); $command = ParaTestCommand::applicationFactory($testSuite->rootPath); $command->setAutoExit(false); $command->setName('Pest'); $command->setVersion(version()); $exitCode = $command->run(new ArgvInput($filteredArguments)); $exitCode = (new CallsAddsOutput())($exitCode); exit($exitCode); } private function markTestSuiteAsParallelSubProcessIfRequired(): void { if ((int) Arr::get($_SERVER, 'PARATEST') === 1) { $_SERVER['PEST_PARALLEL'] = 1; } } private function askUserToInstallParatest(): void { Container::getInstance()->get(OutputInterface::class)->writeln([ 'Parallel support requires ParaTest, which is not installed.', 'Please run composer require --dev brianium/paratest to install ParaTest.', ]); } }