From 9a77ff6b96c2aa3641c0b32286e6030ef99c0608 Mon Sep 17 00:00:00 2001 From: ChrisAbner <48162172+ChrisAbner@users.noreply.github.com> Date: Tue, 3 Nov 2026 10:51:33 -0500 Subject: [PATCH] fix: let extensions register event subscribers in --parallel mode (#2002) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksandr Štšepelin Co-authored-by: Punyapal Shah Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com> --- .../Parallel/Paratest/WrapperRunner.php | 2 -- tests/.snapshots/success.txt | 3 ++- .../Suites/ParallelExtensionSubscriber.xml | 15 ++++++++++++ .../PassingTest.php | 3 +++ .../SubscribingExtension.php | 23 +++++++++++++++++++ .../ParallelExtensionSubscriber/bootstrap.php | 4 ++++ tests/Visual/Parallel.php | 15 ++++++++++++ 7 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 tests/Fixtures/Suites/ParallelExtensionSubscriber.xml create mode 100644 tests/Fixtures/Suites/ParallelExtensionSubscriber/PassingTest.php create mode 100644 tests/Fixtures/Suites/ParallelExtensionSubscriber/SubscribingExtension.php create mode 100644 tests/Fixtures/Suites/ParallelExtensionSubscriber/bootstrap.php diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 2cb01a10..f4118c65 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -160,8 +160,6 @@ final class WrapperRunner implements RunnerInterface { $directory = dirname(__DIR__); ExcludeList::addDirectory($directory); - TestResultFacade::init(); - EventFacade::instance()->seal(); $suiteLoader = new SuiteLoader( $this->options, $this->output, diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 2b731142..248e4cc7 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -2266,6 +2266,7 @@ ✓ parallel ✓ a parallel test can extend another test with same name ✓ parallel reports invalid datasets as failures + ✓ parallel lets extensions register event subscribers ✓ parallel can have multiple exclude-groups ✓ parallel can have multiple groups @@ -2301,4 +2302,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1628 passed (3596 assertions) + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1629 passed (3599 assertions) diff --git a/tests/Fixtures/Suites/ParallelExtensionSubscriber.xml b/tests/Fixtures/Suites/ParallelExtensionSubscriber.xml new file mode 100644 index 00000000..b825180f --- /dev/null +++ b/tests/Fixtures/Suites/ParallelExtensionSubscriber.xml @@ -0,0 +1,15 @@ + + + + + ParallelExtensionSubscriber/PassingTest.php + + + + + + diff --git a/tests/Fixtures/Suites/ParallelExtensionSubscriber/PassingTest.php b/tests/Fixtures/Suites/ParallelExtensionSubscriber/PassingTest.php new file mode 100644 index 00000000..915336ab --- /dev/null +++ b/tests/Fixtures/Suites/ParallelExtensionSubscriber/PassingTest.php @@ -0,0 +1,3 @@ +assertTrue(true); diff --git a/tests/Fixtures/Suites/ParallelExtensionSubscriber/SubscribingExtension.php b/tests/Fixtures/Suites/ParallelExtensionSubscriber/SubscribingExtension.php new file mode 100644 index 00000000..45c776db --- /dev/null +++ b/tests/Fixtures/Suites/ParallelExtensionSubscriber/SubscribingExtension.php @@ -0,0 +1,23 @@ +registerSubscriber(new class implements PreparedSubscriber + { + public function notify(Prepared $event): void {} + }); + } +} diff --git a/tests/Fixtures/Suites/ParallelExtensionSubscriber/bootstrap.php b/tests/Fixtures/Suites/ParallelExtensionSubscriber/bootstrap.php new file mode 100644 index 00000000..2bcaf9d6 --- /dev/null +++ b/tests/Fixtures/Suites/ParallelExtensionSubscriber/bootstrap.php @@ -0,0 +1,4 @@ +toContain('Parallel: 3 processes'); })->skipOnWindows(); +test('parallel lets extensions register event subscribers', function (): void { + $process = new Process( + ['php', 'bin/pest', '--configuration', 'tests/Fixtures/Suites/ParallelExtensionSubscriber.xml', '--parallel', '--processes=2'], + dirname(__DIR__, 2), + ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'], + ); + + $process->run(); + + expect($process->getExitCode())->toBe(0) + ->and(removeAnsiEscapeSequences($process->getOutput())) + ->not->toContain('failed') + ->toContain('Parallel: 2 processes'); +})->skipOnWindows(); + test('parallel can have multiple exclude-groups', function () use ($run): void { $singleExclude = $run('--exclude-group=integration'); $doubleExclude = $run('--exclude-group=integration', '--exclude-group=container');