mirror of
https://github.com/pestphp/pest.git
synced 2026-12-04 23:15:06 +01:00
9dc8c1d5cb
* fix: honor all stop-on-* flags in parallel mode Previously --stop-on-failure was the only flag honored in parallel mode, and it only cleared pending tests when the exit code was non-zero. The rest (--stop-on-defect, --stop-on-error, --stop-on-risky, --stop-on-incomplete, --stop-on-warning, --stop-on-notice, --stop-on-deprecation, --stop-on-skipped) were silently ignored. WrapperRunner now precomputes the set of progress-file characters that should trigger a stop (F, E, R, I, W, N, D, S) based on the configured flags, and scans each worker's progress file for them after every cycle. Once any matching outcome is seen, the pending queue is cleared. Up to N-1 in-flight tests (where N is --processes) can still complete after the first stop-worthy outcome — stopping them mid-run would risk corrupting shared state. Closes #1463. * fix: preserve parallel stop conditions on Pest 5 * test: expand parallel stop-on regression coverage
77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pest\Plugins\Parallel\Handlers;
|
|
|
|
use Pest\Contracts\Plugins\HandlesArguments;
|
|
use Pest\Plugins\Parallel\Contracts\HandlersWorkerArguments;
|
|
use Symfony\Component\Console\Input\InputDefinition;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
final class StopOn implements HandlersWorkerArguments, HandlesArguments
|
|
{
|
|
private const array OPTIONS = [
|
|
'--stop-on-defect',
|
|
'--stop-on-error',
|
|
'--stop-on-failure',
|
|
'--stop-on-warning',
|
|
'--stop-on-risky',
|
|
'--stop-on-deprecation',
|
|
'--stop-on-notice',
|
|
'--stop-on-skipped',
|
|
'--stop-on-incomplete',
|
|
];
|
|
|
|
public function handleArguments(array $arguments): array
|
|
{
|
|
foreach ($arguments as $index => $argument) {
|
|
[$option, $value] = array_pad(explode('=', $argument, 2), 2, '');
|
|
|
|
if (in_array($option, self::OPTIONS, true)
|
|
&& in_array($value, ['', '0'], true)) {
|
|
$arguments[$index] = $option.'=1';
|
|
}
|
|
}
|
|
|
|
return $arguments;
|
|
}
|
|
|
|
public function handleWorkerArguments(array $arguments): array
|
|
{
|
|
$arguments = array_values($arguments);
|
|
|
|
foreach ($arguments as $index => $argument) {
|
|
if (! in_array($argument, self::OPTIONS, true)
|
|
|| ! isset($arguments[$index + 1])
|
|
|| str_starts_with($arguments[$index + 1], '--')) {
|
|
continue;
|
|
}
|
|
|
|
$arguments[$index] .= '='.$arguments[$index + 1];
|
|
unset($arguments[$index + 1]);
|
|
}
|
|
|
|
return array_values($arguments);
|
|
}
|
|
|
|
public static function configureOptions(InputDefinition $definition): void
|
|
{
|
|
$options = $definition->getOptions();
|
|
|
|
foreach (self::OPTIONS as $argument) {
|
|
$name = substr($argument, 2);
|
|
$option = $options[$name];
|
|
$options[$name] = new InputOption(
|
|
$name,
|
|
$option->getShortcut(),
|
|
InputOption::VALUE_OPTIONAL,
|
|
$option->getDescription(),
|
|
false,
|
|
);
|
|
}
|
|
|
|
$definition->setOptions($options);
|
|
}
|
|
}
|