chore: different refactors

This commit is contained in:
Nuno Maduro
2023-02-11 16:07:30 +00:00
parent e1406554fc
commit 8eaf4859ff
19 changed files with 207 additions and 165 deletions

View File

@ -17,6 +17,7 @@ use Symfony\Component\Console\Output\OutputInterface;
$_SERVER['COLLISION_PRINTER'] = 'DefaultPrinter';
$args = $_SERVER['argv'];
$dirty = false;
$todo = false;
@ -68,11 +69,11 @@ use Symfony\Component\Console\Output\OutputInterface;
// Get $rootPath based on $autoloadPath
$rootPath = dirname($autoloadPath, 2);
$argv = new ArgvInput();
$input = new ArgvInput();
$testSuite = TestSuite::getInstance(
$rootPath,
$argv->getParameterOption('--test-directory', (new ConfigLoader($rootPath))->getTestsDirectory()),
$input->getParameterOption('--test-directory', (new ConfigLoader($rootPath))->getTestsDirectory()),
);
if ($dirty) {
@ -83,19 +84,13 @@ use Symfony\Component\Console\Output\OutputInterface;
$testSuite->tests->addTestCaseMethodFilter(new TodoTestCaseFilter());
}
$isDecorated = $argv->getParameterOption('--colors', 'always') !== 'never';
$isDecorated = $input->getParameterOption('--colors', 'always') !== 'never';
$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated);
$container = Container::getInstance();
$container->add(TestSuite::class, $testSuite);
$container->add(OutputInterface::class, $output);
$container->add(InputInterface::class, $argv);
$container->add(Container::class, $container);
$kernel = Kernel::boot($testSuite, $input, $output);
$kernel = Kernel::boot();
$result = $kernel->handle($output, $args);
$result = $kernel->handle($args);
$kernel->shutdown();

View File

@ -7,37 +7,31 @@ use ParaTest\WrapperRunner\WrapperWorker;
use Pest\ConfigLoader;
use Pest\Kernel;
use Pest\Plugins\Actions\CallsHandleArguments;
use Pest\Support\Container;
use Pest\TestCaseMethodFilters\TodoTestCaseFilter;
use Pest\TestSuite;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
$bootPest = (static function (): void {
$argv = new ArgvInput();
$parentProcessArgv = new ArgvInput(json_decode($_SERVER['PEST_PARALLEL_ARGV']));
$workerArgv = new ArgvInput();
$masterArgv = new ArgvInput(json_decode($_SERVER['PEST_PARALLEL_ARGV']));
$rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2);
$testSuite = TestSuite::getInstance(
$rootPath,
$argv->getParameterOption('--test-directory', (new ConfigLoader($rootPath))->getTestsDirectory()),
);
$testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption(
'--test-directory',
(new ConfigLoader($rootPath))->getTestsDirectory()
));
if ($parentProcessArgv->hasParameterOption('--todo')) {
if ($masterArgv->hasParameterOption('--todo')) {
$testSuite->tests->addTestCaseMethodFilter(new TodoTestCaseFilter());
}
$input = new ArgvInput();
$output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
$container = Container::getInstance();
$container->add(TestSuite::class, $testSuite);
$container->add(OutputInterface::class, $output);
$container->add(InputInterface::class, $argv);
$container->add(Container::class, $container);
Kernel::boot();
Kernel::boot($testSuite, $input, $output);
});
(static function () use ($bootPest): void {
@ -104,10 +98,10 @@ $bootPest = (static function (): void {
$testPath = fgets(STDIN);
if ($testPath === false || $testPath === WrapperWorker::COMMAND_EXIT) {
$application->end();
exit;
}
// It must be a 1 byte string to ensure filesize() is equal to the number of tests executed
$exitCode = $application->runTest(trim($testPath));
fwrite($statusFile, (string) $exitCode);