Files
pest/tests/Visual/ParallelIncludePathTrailingSpace.php
T
Jhon Farias 12bddc0137 fix(parallel): support --include-path (#2075)
* fix(parallel): support --include-path

* fix(parallel): keep an include path with an equals sign in the parent process

* fix(parallel): apply the include path before the bootstrap file

* chore(rector): skip the parallel include path fixture

* fix(parallel): apply the command line include path before the XML one in the bootstrap file

Register `--include-path` on the ParaTest command, so ParaTest passes it to
the PHPUnit configuration of the parent process. PHPUnit then puts the
command line paths before the XML `<includePath>` before it includes the
`--bootstrap` file.

Read the value and the arguments the option consumes through PHPUnit's
`Builder`, and write the value back in a form that PHPUnit reads unchanged,
for the parent process and for each worker. Run the include path handler
first, so it reads only the arguments of the user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(parallel): declare strict types and refresh the success snapshot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
2026-12-04 01:48:02 +05:30

28 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
use Symfony\Component\Process\Process;
test('parallel workers keep the trailing space of an include path as serial phpunit does', function (): void {
$script = <<<'PHP_WRAP'
require "vendor/autoload.php";
$read = fn (array $arguments): string => (new PHPUnit\TextUI\CliArguments\Builder(PHPUnit\Event\Facade::emitter()))->fromParameters(["phpunit", ...$arguments])->includePath();
$arguments = ["--include-path=lib =extra"];
$handler = new Pest\Plugins\Parallel\Handlers\IncludePath;
$forwarded = $handler->handleArguments($arguments);
echo json_encode(["serial" => $read($arguments), "forwarded" => $read($forwarded), "worker" => $read($handler->handleWorkerArguments([]))]);
PHP_WRAP;
$process = new Process(['php', '-r', $script], dirname(__DIR__, 2));
$process->run();
expect($process->getExitCode())->toBe(0, $process->getErrorOutput())
->and(json_decode($process->getOutput(), true))->toBe([
'serial' => 'lib ',
'forwarded' => 'lib ',
'worker' => 'lib ',
]);
});