mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
fix(sharding): strip --runner from the --list-tests sub-process (#2004)
* fix(sharding): strip `--runner` from the `--list-tests` sub-process * fix(sharding): strip a space-separated `--runner` value too Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test: count the two new shard tests in the visual suite totals Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Apa <mikko@apaiko.fi> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+28
-5
@@ -190,11 +190,34 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable
|
||||
*/
|
||||
private function removeParallelArguments(array $arguments): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
$arguments,
|
||||
fn (string $argument): bool => ! in_array($argument, ['--parallel', '-p'], strict: true)
|
||||
&& ! str_starts_with($argument, '--processes'),
|
||||
));
|
||||
$filtered = [];
|
||||
$skipNext = false;
|
||||
|
||||
foreach ($arguments as $argument) {
|
||||
if ($skipNext) {
|
||||
$skipNext = false;
|
||||
|
||||
if (! str_starts_with($argument, '-')) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($argument === '--runner') {
|
||||
$skipNext = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($argument, ['--parallel', '-p'], strict: true)
|
||||
|| str_starts_with($argument, '--processes')
|
||||
|| str_starts_with($argument, '--runner=')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filtered[] = $argument;
|
||||
}
|
||||
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1888,6 +1888,8 @@
|
||||
✓ buildListTestsCommand → it forwards --test-directory even when input arguments include one
|
||||
✓ buildListTestsCommand → it strips --processes=N when building the list-tests command
|
||||
✓ buildListTestsCommand → it strips --processes N (space-separated) when building the list-tests command
|
||||
✓ buildListTestsCommand → it strips --runner when building the list-tests command
|
||||
✓ buildListTestsCommand → it strips a space-separated --runner and its value when building the list-tests command
|
||||
✓ addOutput → it displays shard information after test execution
|
||||
✓ addOutput → it uses singular form for single test file
|
||||
✓ addOutput → it returns original exit code when shard is not set
|
||||
@@ -2323,4 +2325,4 @@
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1650 passed (3653 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1652 passed (3655 assertions)
|
||||
@@ -525,6 +525,44 @@ describe('buildListTestsCommand', function (): void {
|
||||
->and($command)->toContain('--update-shards')
|
||||
->and($command)->toContain('--test-directory=tests');
|
||||
});
|
||||
|
||||
it('strips --runner when building the list-tests command', function (): void {
|
||||
$output = new BufferedOutput;
|
||||
$shard = new Shard($output);
|
||||
|
||||
$reflection = new ReflectionClass($shard);
|
||||
$method = $reflection->getMethod('buildListTestsCommand');
|
||||
|
||||
$command = $method->invoke($shard, ['artisan', 'test', '--runner=\\Illuminate\\Testing\\ParallelRunner', '--shard=1/3'], 'tests');
|
||||
|
||||
expect($command)->toBe([
|
||||
PHP_BINARY,
|
||||
'artisan',
|
||||
'test',
|
||||
'--shard=1/3',
|
||||
'--test-directory=tests',
|
||||
'--list-tests',
|
||||
]);
|
||||
});
|
||||
|
||||
it('strips a space-separated --runner and its value when building the list-tests command', function (): void {
|
||||
$output = new BufferedOutput;
|
||||
$shard = new Shard($output);
|
||||
|
||||
$reflection = new ReflectionClass($shard);
|
||||
$method = $reflection->getMethod('buildListTestsCommand');
|
||||
|
||||
$command = $method->invoke($shard, ['artisan', 'test', '--runner', '\\Illuminate\\Testing\\ParallelRunner', '--shard=1/3'], 'tests');
|
||||
|
||||
expect($command)->toBe([
|
||||
PHP_BINARY,
|
||||
'artisan',
|
||||
'test',
|
||||
'--shard=1/3',
|
||||
'--test-directory=tests',
|
||||
'--list-tests',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addOutput', function (): void {
|
||||
|
||||
@@ -20,7 +20,7 @@ test('parallel', function () use ($run): void {
|
||||
$output = $run('--exclude-group=integration');
|
||||
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
|
||||
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 29 skipped, 1622 passed (3577 assertions)';
|
||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 29 skipped, 1624 passed (3579 assertions)';
|
||||
|
||||
expect($output)
|
||||
->toContain("Tests: {$expected}")
|
||||
|
||||
Reference in New Issue
Block a user