Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Plugins/Parallel/Paratest/WrapperRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use ParaTest\WrapperRunner\WrapperWorker;
use Pest\Result;
use Pest\TestSuite;
use PHPUnit\Event\Facade as EventFacade;
use PHPUnit\Event\Test\AfterLastTestMethodFailed;
use PHPUnit\Event\TestRunner\WarningTriggered;
use PHPUnit\Runner\CodeCoverage;
Expand Down Expand Up @@ -148,8 +147,6 @@ public function run(): int
$directory = dirname(__DIR__);
assert($directory !== '');
ExcludeList::addDirectory($directory);
TestResultFacade::init();
EventFacade::instance()->seal();
$suiteLoader = new SuiteLoader(
$this->options,
$this->output,
Expand Down
5 changes: 4 additions & 1 deletion tests/.snapshots/success.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,9 @@
PASS Tests\Visual\ParallelNestedDatasets
✓ parallel loads nested datasets from nested directories

PASS Tests\Visual\ParallelRunnerWarning
✓ parallel bootstraps extensions that register subscribers the same way sequential does

PASS Tests\Visual\SingleTestOrDirectory
✓ allows to run a single test
✓ allows to run a directory
Expand Down Expand Up @@ -1938,4 +1941,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, 35 skipped, 1329 passed (3010 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1330 passed (3015 assertions)
3 changes: 3 additions & 0 deletions tests/.tests/ParallelRunnerWarning/PassingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

it('passes')->assertTrue(true);
25 changes: 25 additions & 0 deletions tests/.tests/ParallelRunnerWarning/SubscribingExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Pest\Tests\ParallelRunnerWarning;

use PHPUnit\Event\Facade as EventFacade;
use PHPUnit\Event\Test\Prepared;
use PHPUnit\Event\Test\PreparedSubscriber;
use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade as ExtensionFacade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;

final class SubscribingExtension implements Extension
{
public function bootstrap(Configuration $configuration, ExtensionFacade $facade, ParameterCollection $parameters): void
{
EventFacade::instance()->registerSubscriber(new class implements PreparedSubscriber {
public function notify(Prepared $event): void
{
}
});
}
}
6 changes: 6 additions & 0 deletions tests/.tests/ParallelRunnerWarning/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

declare(strict_types=1);

require_once __DIR__.'/../../../vendor/autoload.php';
require_once __DIR__.'/SubscribingExtension.php';
16 changes: 16 additions & 0 deletions tests/.tests/ParallelRunnerWarning/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
bootstrap="./bootstrap.php"
failOnPhpunitWarning="true"
colors="true"
>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">.</directory>
</testsuite>
</testsuites>
<extensions>
<bootstrap class="Pest\Tests\ParallelRunnerWarning\SubscribingExtension"/>
</extensions>
</phpunit>
30 changes: 30 additions & 0 deletions tests/Visual/ParallelRunnerWarning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Symfony\Component\Process\Process;

$run = function (string ...$args) {
$process = new Process(
array_merge(['php', 'bin/pest', '--parallel', '--processes=2'], $args),
dirname(__DIR__, 2),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
);

$process->run();

return [
'output' => removeAnsiEscapeSequences($process->getOutput()),
'exitCode' => $process->getExitCode(),
];
};

test('parallel bootstraps extensions that register subscribers the same way sequential does', function () use ($run) {
$result = $run('-c', 'tests/.tests/ParallelRunnerWarning/phpunit.xml');

expect($result['output'])
->toContain('2 passed')
->toContain('Parallel: 2 processes')
->not->toContain('warning')
->not->toContain('Bootstrapping of extension');

expect($result['exitCode'])->toBe(0);
})->skipOnWindows();
Loading