mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 01:37:21 +01:00
wip
This commit is contained in:
@ -27,7 +27,7 @@ final class Laravel
|
||||
$this->setLaravelParallelRunner();
|
||||
|
||||
foreach ($args as $value) {
|
||||
if (str_starts_with($value, '--runner')) {
|
||||
if (str_starts_with((string) $value, '--runner')) {
|
||||
$args = $this->popArgument($value, $args);
|
||||
}
|
||||
}
|
||||
@ -41,9 +41,7 @@ final class Laravel
|
||||
exit('Using parallel with Pest requires Laravel v8.55.0 or higher.');
|
||||
}
|
||||
|
||||
ParallelRunner::resolveRunnerUsing(function (Options $options, OutputInterface $output): RunnerInterface {
|
||||
return new WrapperRunner($options, $output);
|
||||
});
|
||||
ParallelRunner::resolveRunnerUsing(fn(Options $options, OutputInterface $output): RunnerInterface => new WrapperRunner($options, $output));
|
||||
}
|
||||
|
||||
private static function isALaravelApplication(): bool
|
||||
|
||||
@ -14,16 +14,18 @@ use Symfony\Component\Console\Input\ArgvInput;
|
||||
final class Parallel
|
||||
{
|
||||
use HandleArguments;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const ARGS_TO_REMOVE = [
|
||||
'--parallel',
|
||||
'-p',
|
||||
'--no-output',
|
||||
];
|
||||
|
||||
public function handle(array $args): array
|
||||
{
|
||||
$argsToRemove = [
|
||||
'--parallel',
|
||||
'-p',
|
||||
'--no-output',
|
||||
];
|
||||
|
||||
$args = array_reduce($argsToRemove, fn ($args, $arg) => $this->popArgument($arg, $args), $args);
|
||||
$args = array_reduce(self::ARGS_TO_REMOVE, fn ($args, $arg): array => $this->popArgument($arg, $args), $args);
|
||||
|
||||
return $this->pushArgument('--runner=' . WrapperRunner::class, $args);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
{
|
||||
private const CYCLE_SLEEP = 10000;
|
||||
private readonly ResultPrinter $printer;
|
||||
private Timer $timer;
|
||||
private readonly Timer $timer;
|
||||
|
||||
/** @var non-empty-string[] */
|
||||
private array $pending = [];
|
||||
@ -131,7 +131,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
{
|
||||
$batchSize = $this->options->maxBatchSize;
|
||||
|
||||
while (count($this->pending) > 0 && count($this->workers) > 0) {
|
||||
while ($this->pending !== [] && $this->workers !== []) {
|
||||
foreach ($this->workers as $token => $worker) {
|
||||
if (! $worker->isRunning()) {
|
||||
throw $worker->getWorkerCrashedException();
|
||||
@ -178,7 +178,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
private function waitForAllToFinish(): void
|
||||
{
|
||||
$stopped = [];
|
||||
while (count($this->workers) > 0) {
|
||||
while ($this->workers !== []) {
|
||||
foreach ($this->workers as $index => $worker) {
|
||||
if ($worker->isRunning()) {
|
||||
if (! isset($stopped[$index]) && $worker->isFree()) {
|
||||
@ -307,7 +307,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
return $exitcode;
|
||||
}
|
||||
|
||||
protected function generateCodeCoverageReports(): void
|
||||
private function generateCodeCoverageReports(): void
|
||||
{
|
||||
if ($this->coverageFiles === []) {
|
||||
return;
|
||||
@ -361,7 +361,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
|
||||
$tests = array_filter(
|
||||
$suiteLoader->files,
|
||||
fn(string $filename) => ! str_ends_with($filename, "eval()'d code")
|
||||
fn(string $filename): bool => ! str_ends_with($filename, "eval()'d code")
|
||||
);
|
||||
|
||||
return [...$tests, ...TestSuite::getInstance()->tests->getFilenames()];
|
||||
|
||||
@ -25,6 +25,8 @@ final class CompactPrinter
|
||||
{
|
||||
private readonly Terminal $terminal;
|
||||
|
||||
private readonly ConsoleOutputInterface $output;
|
||||
|
||||
private readonly Style $style;
|
||||
|
||||
private int $compactProcessed = 0;
|
||||
|
||||
Reference in New Issue
Block a user