mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
WIP
This commit is contained in:
committed by
Nuno Maduro
parent
dd840f8861
commit
a34001faf0
@ -6,7 +6,6 @@ use ParaTest\WrapperRunner\ApplicationForWrapperWorker;
|
|||||||
use ParaTest\WrapperRunner\WrapperWorker;
|
use ParaTest\WrapperRunner\WrapperWorker;
|
||||||
use Pest\ConfigLoader;
|
use Pest\ConfigLoader;
|
||||||
use Pest\Kernel;
|
use Pest\Kernel;
|
||||||
use Pest\Plugins\Actions\CallsAddsOutput;
|
|
||||||
use Pest\Plugins\Actions\CallsHandleArguments;
|
use Pest\Plugins\Actions\CallsHandleArguments;
|
||||||
use Pest\Support\Container;
|
use Pest\Support\Container;
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|||||||
@ -5,21 +5,14 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Logging\TeamCity;
|
namespace Pest\Logging\TeamCity;
|
||||||
|
|
||||||
use NunoMaduro\Collision\Adapters\Phpunit\State;
|
use NunoMaduro\Collision\Adapters\Phpunit\State;
|
||||||
use NunoMaduro\Collision\Adapters\Phpunit\TestResult;
|
|
||||||
use Pest\Exceptions\ShouldNotHappen;
|
use Pest\Exceptions\ShouldNotHappen;
|
||||||
use Pest\Support\StateGenerator;
|
use Pest\Support\StateGenerator;
|
||||||
use Pest\Support\Str;
|
use Pest\Support\Str;
|
||||||
use PHPUnit\Event\Code\Test;
|
use PHPUnit\Event\Code\Test;
|
||||||
use PHPUnit\Event\Code\TestDox;
|
|
||||||
use PHPUnit\Event\Code\TestMethod;
|
use PHPUnit\Event\Code\TestMethod;
|
||||||
use PHPUnit\Event\Code\Throwable;
|
use PHPUnit\Event\Code\Throwable;
|
||||||
use PHPUnit\Event\Test\Errored;
|
|
||||||
use PHPUnit\Event\TestData\TestDataCollection;
|
|
||||||
use PHPUnit\Event\TestSuite\TestSuite;
|
use PHPUnit\Event\TestSuite\TestSuite;
|
||||||
use PHPUnit\Framework\Exception as FrameworkException;
|
use PHPUnit\Framework\Exception as FrameworkException;
|
||||||
use PHPUnit\Framework\IncompleteTestError;
|
|
||||||
use PHPUnit\Framework\SkippedWithMessageException;
|
|
||||||
use PHPUnit\Metadata\MetadataCollection;
|
|
||||||
use PHPUnit\TestRunner\TestResult\TestResult as PhpUnitTestResult;
|
use PHPUnit\TestRunner\TestResult\TestResult as PhpUnitTestResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,20 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Pest\Plugins;
|
namespace Pest\Plugins;
|
||||||
|
|
||||||
use ParaTest\ParaTestCommand;
|
use ParaTest\ParaTestCommand;
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
use Pest\Plugins\Actions\CallsAddsOutput;
|
use Pest\Plugins\Actions\CallsAddsOutput;
|
||||||
use Pest\Plugins\Concerns\HandleArguments;
|
use Pest\Plugins\Concerns\HandleArguments;
|
||||||
use Pest\Plugins\Parallel\Handlers\Laravel;
|
|
||||||
use Pest\Support\Arr;
|
use Pest\Support\Arr;
|
||||||
use Pest\Support\Container;
|
use Pest\Support\Container;
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
use function Pest\version;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use function Pest\version;
|
|
||||||
|
|
||||||
final class Parallel implements HandlesArguments
|
final class Parallel implements HandlesArguments
|
||||||
{
|
{
|
||||||
@ -22,7 +23,7 @@ final class Parallel implements HandlesArguments
|
|||||||
|
|
||||||
private const HANDLERS = [
|
private const HANDLERS = [
|
||||||
Parallel\Handlers\Parallel::class,
|
Parallel\Handlers\Parallel::class,
|
||||||
Laravel::class,
|
Parallel\Handlers\Laravel::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function handleArguments(array $arguments): array
|
public function handleArguments(array $arguments): array
|
||||||
@ -41,6 +42,7 @@ final class Parallel implements HandlesArguments
|
|||||||
if ($this->hasArgument('--parallel', $arguments)) {
|
if ($this->hasArgument('--parallel', $arguments)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->hasArgument('-p', $arguments);
|
return $this->hasArgument('-p', $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ namespace Pest\Plugins\Parallel\Handlers;
|
|||||||
|
|
||||||
use Pest\Plugins\Concerns\HandleArguments;
|
use Pest\Plugins\Concerns\HandleArguments;
|
||||||
use Pest\Plugins\Parallel\Paratest\WrapperRunner;
|
use Pest\Plugins\Parallel\Paratest\WrapperRunner;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -14,6 +13,7 @@ use Symfony\Component\Console\Input\ArgvInput;
|
|||||||
final class Parallel
|
final class Parallel
|
||||||
{
|
{
|
||||||
use HandleArguments;
|
use HandleArguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -4,6 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Plugins\Parallel\Paratest;
|
namespace Pest\Plugins\Parallel\Paratest;
|
||||||
|
|
||||||
|
use function array_merge;
|
||||||
|
use function array_merge_recursive;
|
||||||
|
use function array_shift;
|
||||||
|
use function assert;
|
||||||
|
use function count;
|
||||||
|
use const DIRECTORY_SEPARATOR;
|
||||||
|
use function dirname;
|
||||||
|
use function file_get_contents;
|
||||||
|
use function max;
|
||||||
use ParaTest\Coverage\CoverageMerger;
|
use ParaTest\Coverage\CoverageMerger;
|
||||||
use ParaTest\JUnit\LogMerger;
|
use ParaTest\JUnit\LogMerger;
|
||||||
use ParaTest\JUnit\Writer;
|
use ParaTest\JUnit\Writer;
|
||||||
@ -19,49 +28,47 @@ use PHPUnit\TestRunner\TestResult\TestResult;
|
|||||||
use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry;
|
use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry;
|
||||||
use PHPUnit\TextUI\ShellExitCodeCalculator;
|
use PHPUnit\TextUI\ShellExitCodeCalculator;
|
||||||
use PHPUnit\Util\ExcludeList;
|
use PHPUnit\Util\ExcludeList;
|
||||||
|
use function realpath;
|
||||||
use SebastianBergmann\Timer\Timer;
|
use SebastianBergmann\Timer\Timer;
|
||||||
use SplFileInfo;
|
use SplFileInfo;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Process\PhpExecutableFinder;
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
|
|
||||||
use function array_merge;
|
|
||||||
use function array_merge_recursive;
|
|
||||||
use function array_shift;
|
|
||||||
use function assert;
|
|
||||||
use function count;
|
|
||||||
use function dirname;
|
|
||||||
use function file_get_contents;
|
|
||||||
use function max;
|
|
||||||
use function realpath;
|
|
||||||
use function unlink;
|
use function unlink;
|
||||||
use function unserialize;
|
use function unserialize;
|
||||||
use function usleep;
|
use function usleep;
|
||||||
|
|
||||||
use const DIRECTORY_SEPARATOR;
|
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
final class WrapperRunner implements RunnerInterface
|
final class WrapperRunner implements RunnerInterface
|
||||||
{
|
{
|
||||||
private const CYCLE_SLEEP = 10000;
|
private const CYCLE_SLEEP = 10000;
|
||||||
|
|
||||||
private readonly ResultPrinter $printer;
|
private readonly ResultPrinter $printer;
|
||||||
|
|
||||||
private readonly Timer $timer;
|
private readonly Timer $timer;
|
||||||
|
|
||||||
/** @var non-empty-string[] */
|
/** @var non-empty-string[] */
|
||||||
private array $pending = [];
|
private array $pending = [];
|
||||||
|
|
||||||
private int $exitcode = -1;
|
private int $exitcode = -1;
|
||||||
|
|
||||||
/** @var array<positive-int,WrapperWorker> */
|
/** @var array<positive-int,WrapperWorker> */
|
||||||
private array $workers = [];
|
private array $workers = [];
|
||||||
|
|
||||||
/** @var array<int,int> */
|
/** @var array<int,int> */
|
||||||
private array $batches = [];
|
private array $batches = [];
|
||||||
|
|
||||||
/** @var list<SplFileInfo> */
|
/** @var list<SplFileInfo> */
|
||||||
private array $testresultFiles = [];
|
private array $testresultFiles = [];
|
||||||
|
|
||||||
/** @var list<SplFileInfo> */
|
/** @var list<SplFileInfo> */
|
||||||
private array $coverageFiles = [];
|
private array $coverageFiles = [];
|
||||||
|
|
||||||
/** @var list<SplFileInfo> */
|
/** @var list<SplFileInfo> */
|
||||||
private array $junitFiles = [];
|
private array $junitFiles = [];
|
||||||
|
|
||||||
/** @var list<SplFileInfo> */
|
/** @var list<SplFileInfo> */
|
||||||
private array $teamcityFiles = [];
|
private array $teamcityFiles = [];
|
||||||
|
|
||||||
/** @var list<SplFileInfo> */
|
/** @var list<SplFileInfo> */
|
||||||
private array $testdoxFiles = [];
|
private array $testdoxFiles = [];
|
||||||
|
|
||||||
@ -100,10 +107,13 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
|
|
||||||
public function run(): int
|
public function run(): int
|
||||||
{
|
{
|
||||||
ExcludeList::addDirectory(dirname(__DIR__));
|
$directory = dirname(__DIR__);
|
||||||
|
assert(strlen($directory) > 0);
|
||||||
|
ExcludeList::addDirectory($directory);
|
||||||
|
|
||||||
TestResultFacade::init();
|
TestResultFacade::init();
|
||||||
EventFacade::seal();
|
EventFacade::seal();
|
||||||
$suiteLoader = new SuiteLoader($this->options, $this->output, $this->codeCoverageFilterRegistry,);
|
$suiteLoader = new SuiteLoader($this->options, $this->output, $this->codeCoverageFilterRegistry);
|
||||||
$this->pending = $this->getTestFiles($suiteLoader);
|
$this->pending = $this->getTestFiles($suiteLoader);
|
||||||
|
|
||||||
$result = TestResultFacade::result();
|
$result = TestResultFacade::result();
|
||||||
@ -122,7 +132,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
|
|
||||||
private function startWorkers(): void
|
private function startWorkers(): void
|
||||||
{
|
{
|
||||||
for ($token = 1; $token <= $this->options->processes; ++$token) {
|
for ($token = 1; $token <= $this->options->processes; $token++) {
|
||||||
$this->startWorker($token);
|
$this->startWorker($token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +153,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
|
|
||||||
$this->flushWorker($worker);
|
$this->flushWorker($worker);
|
||||||
|
|
||||||
if ($batchSize !== null && $batchSize !== 0 && $this->batches[$token] === $batchSize) {
|
if ($batchSize !== 0 && $this->batches[$token] === $batchSize) {
|
||||||
$this->destroyWorker($token);
|
$this->destroyWorker($token);
|
||||||
$worker = $this->startWorker($token);
|
$worker = $this->startWorker($token);
|
||||||
}
|
}
|
||||||
@ -357,7 +367,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
*/
|
*/
|
||||||
private function getTestFiles(SuiteLoader $suiteLoader): array
|
private function getTestFiles(SuiteLoader $suiteLoader): array
|
||||||
{
|
{
|
||||||
$this->debug(sprintf("Found %d test file%s", count($suiteLoader->files), count($suiteLoader->files) === 1 ? '' : 's'));
|
$this->debug(sprintf('Found %d test file%s', count($suiteLoader->files), count($suiteLoader->files) === 1 ? '' : 's'));
|
||||||
|
|
||||||
$tests = array_filter(
|
$tests = array_filter(
|
||||||
$suiteLoader->files,
|
$suiteLoader->files,
|
||||||
|
|||||||
Reference in New Issue
Block a user