mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Adds Pest output to parallel.
This commit is contained in:
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Pest\Console\Paratest;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use function array_merge;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use ParaTest\Runners\PHPUnit\ExecutableTest;
|
||||
@ -22,11 +23,23 @@ final class PestRunnerWorker
|
||||
{
|
||||
/** @var ExecutableTest */
|
||||
private $executableTest;
|
||||
|
||||
/** @var Process */
|
||||
private $process;
|
||||
|
||||
public function __construct(ExecutableTest $executableTest, Options $options, int $token)
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
public static $additionalOutput = [];
|
||||
|
||||
public function __construct(OutputInterface $output, ExecutableTest $executableTest, Options $options, int $token)
|
||||
{
|
||||
$this->output = $output;
|
||||
$this->executableTest = $executableTest;
|
||||
|
||||
$phpFinder = new PhpExecutableFinder();
|
||||
@ -81,7 +94,28 @@ final class PestRunnerWorker
|
||||
*/
|
||||
public function stop(): ?int
|
||||
{
|
||||
return $this->process->stop();
|
||||
$exitCode = $this->process->stop();
|
||||
$this->handleOutput($this->process->getOutput());
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
private function handleOutput(string $output)
|
||||
{
|
||||
$matches = [];
|
||||
preg_match_all("/^\\n/m", $output, $matches, PREG_OFFSET_CAPTURE);
|
||||
|
||||
$overview = substr($output, 0, $matches[0][1][1]);
|
||||
$this->output->write($overview);
|
||||
|
||||
if (count($matches[0]) > 3) {
|
||||
$summarySectionIndex = count($matches[0]) - 2;
|
||||
|
||||
static::$additionalOutput[] = substr(
|
||||
$output,
|
||||
$matches[0][1][1],
|
||||
$matches[0][$summarySectionIndex][1] - $matches[0][1][1],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -84,7 +84,7 @@ final class Runner implements RunnerInterface
|
||||
final public function run(): void
|
||||
{
|
||||
$this->load(new SuiteLoader($this->options, $this->output));
|
||||
$this->printer->start();
|
||||
// $this->printer->start();
|
||||
|
||||
$this->doRun();
|
||||
|
||||
@ -109,7 +109,7 @@ final class Runner implements RunnerInterface
|
||||
$this->sortPending();
|
||||
|
||||
foreach ($this->pending as $pending) {
|
||||
$this->printer->addTest($pending);
|
||||
// $this->printer->addTest($pending);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,11 @@ final class Runner implements RunnerInterface
|
||||
*/
|
||||
private function complete(): void
|
||||
{
|
||||
$this->printer->printResults();
|
||||
foreach(PestRunnerWorker::$additionalOutput as $output) {
|
||||
$this->output->write($output);
|
||||
}
|
||||
PestRunnerWorker::$additionalOutput = [];
|
||||
// $this->printer->printResults();
|
||||
$this->log();
|
||||
$this->logCoverage();
|
||||
$readers = $this->interpreter->getReaders();
|
||||
@ -273,7 +277,7 @@ final class Runner implements RunnerInterface
|
||||
) {
|
||||
$executableTest = array_shift($this->pending);
|
||||
|
||||
$this->running[$token] = new PestRunnerWorker($executableTest, $this->options, $token);
|
||||
$this->running[$token] = new PestRunnerWorker($this->output, $executableTest, $this->options, $token);
|
||||
$this->running[$token]->run();
|
||||
|
||||
if ($this->options->verbosity() < Options::VERBOSITY_VERY_VERBOSE) {
|
||||
@ -314,7 +318,7 @@ final class Runner implements RunnerInterface
|
||||
|
||||
$executableTest = $worker->getExecutableTest();
|
||||
try {
|
||||
$this->printer->printFeedback($executableTest);
|
||||
// $this->printer->printFeedback($executableTest);
|
||||
} catch (EmptyLogFileException $emptyLogFileException) {
|
||||
throw $worker->getWorkerCrashedException($emptyLogFileException);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user