mirror of
https://github.com/pestphp/pest.git
synced 2026-12-05 07:15:33 +01:00
d2c1b99236
* fix: keep added options before the `--` separator Pest added its own options (`--runner`, `--cache-directory`, `--teamcity`, `--no-coverage`, ...) after the `--` that the user gave. PHPUnit and ParaTest then read them as paths, thus `pest -- <path>` and `pest --parallel -- <path>` failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep every option that Pest adds before `--` pushArgument renumbers the list before it searches `--`, because bin/pest unsets options without array_values. Coverage, Shard and the `--teamcity` handling of bin/pest now place their options before `--` too. The changed files lose their comments, as AGENTS.md section 4 asks. 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>
62 lines
2.2 KiB
PHP
62 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Symfony\Component\Process\Process;
|
|
|
|
test('an empty shard runs no tests', function (int $exitCode, string ...$arguments): void {
|
|
$process = new Process([
|
|
PHP_BINARY, 'bin/pest', 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
|
'--colors=never', '--shard=2/2', ...$arguments,
|
|
], dirname(__DIR__, 2));
|
|
|
|
$process->run();
|
|
|
|
expect($process->getExitCode())->toBe($exitCode)
|
|
->and(removeAnsiEscapeSequences($process->getOutput()))
|
|
->toContain('No tests found.', '2 of 2 — 0 files ran, out of 1.')
|
|
->not->toContain('example 1');
|
|
})->with([
|
|
'sequential' => [0],
|
|
'parallel' => [0, '--parallel', '--processes=2'],
|
|
'sequential with fail-on-empty-test-suite' => [1, '--fail-on-empty-test-suite'],
|
|
'parallel with fail-on-empty-test-suite' => [1, '--parallel', '--processes=2', '--fail-on-empty-test-suite'],
|
|
]);
|
|
|
|
test('an empty shard lists no tests', function (): void {
|
|
$process = new Process([
|
|
PHP_BINARY, 'bin/pest', 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
|
'--colors=never', '--shard=2/2', '--list-tests',
|
|
], dirname(__DIR__, 2));
|
|
|
|
$process->run();
|
|
|
|
expect($process->getExitCode())->toBe(0)
|
|
->and($process->getOutput())->toContain('Available test')
|
|
->not->toContain('__pest_evaluable_it_example_1', 'example 1');
|
|
});
|
|
|
|
test('a non-empty shard runs its assigned test', function (): void {
|
|
$process = new Process([
|
|
PHP_BINARY, 'bin/pest', 'tests/Fixtures/DirectoryWithTests/ExampleTest.php',
|
|
'--colors=never', '--shard=1/2',
|
|
], dirname(__DIR__, 2));
|
|
|
|
$process->run();
|
|
|
|
expect($process->getExitCode())->toBe(0)
|
|
->and($process->getOutput())->toContain('1 passed', '1 of 2 — 1 file ran, out of 1.');
|
|
});
|
|
|
|
test('shard accepts a path after the option separator', function (): void {
|
|
$process = new Process(
|
|
['php', 'bin/pest', '--shard=1/2', '--', 'tests/Fixtures/ExampleTest.php'],
|
|
dirname(__DIR__, 2),
|
|
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'],
|
|
);
|
|
|
|
$process->run();
|
|
|
|
expect(removeAnsiEscapeSequences($process->getOutput()))->toContain('Tests: 1 passed (1 assertions)');
|
|
})->skipOnWindows();
|