mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix parallel execution of test class that inherit other class with the same name
This commit is contained in:
@ -92,7 +92,7 @@ $bootPest = (static function (): void {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$exitCode = $application->runTest(trim($testPath));
|
$exitCode = $application->runTest(realpath(trim($testPath)));
|
||||||
|
|
||||||
fwrite($statusFile, (string) $exitCode);
|
fwrite($statusFile, (string) $exitCode);
|
||||||
fflush($statusFile);
|
fflush($statusFile);
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\Fixtures\\Covers\\": "tests/Fixtures/Covers",
|
"Tests\\Fixtures\\Covers\\": "tests/Fixtures/Covers",
|
||||||
|
"Tests\\Fixtures\\Inheritance\\": "tests/Fixtures/Inheritance",
|
||||||
"Tests\\": "tests/PHPUnit/"
|
"Tests\\": "tests/PHPUnit/"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
<directory suffix=".php">./tests</directory>
|
<directory suffix=".php">./tests</directory>
|
||||||
<exclude>./tests/.snapshots</exclude>
|
<exclude>./tests/.snapshots</exclude>
|
||||||
<exclude>./tests/.tests</exclude>
|
<exclude>./tests/.tests</exclude>
|
||||||
|
<exclude>./tests/Fixtures/Inheritance</exclude>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<coverage>
|
<coverage>
|
||||||
|
|||||||
@ -8,4 +8,10 @@
|
|||||||
PASS Tests\Fixtures\ExampleTest
|
PASS Tests\Fixtures\ExampleTest
|
||||||
✓ it example 2
|
✓ it example 2
|
||||||
|
|
||||||
Tests: 2 skipped, 2 passed (2 assertions)
|
WARN Tests\Fixtures\Inheritance\Base\ExampleTest
|
||||||
|
- example
|
||||||
|
|
||||||
|
PASS Tests\Fixtures\Inheritance\ExampleTest
|
||||||
|
✓ example
|
||||||
|
|
||||||
|
Tests: 3 skipped, 3 passed (3 assertions)
|
||||||
|
|||||||
@ -988,6 +988,7 @@
|
|||||||
|
|
||||||
PASS Tests\Visual\Parallel
|
PASS Tests\Visual\Parallel
|
||||||
✓ parallel
|
✓ parallel
|
||||||
|
✓ a parallel test can extend another test with same name
|
||||||
|
|
||||||
PASS Tests\Visual\SingleTestOrDirectory
|
PASS Tests\Visual\SingleTestOrDirectory
|
||||||
✓ allows to run a single test
|
✓ allows to run a single test
|
||||||
@ -1008,4 +1009,4 @@
|
|||||||
PASS Tests\Visual\Version
|
PASS Tests\Visual\Version
|
||||||
✓ visual snapshot of help command output
|
✓ visual snapshot of help command output
|
||||||
|
|
||||||
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 705 passed (1706 assertions)
|
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 706 passed (1707 assertions)
|
||||||
13
tests/Fixtures/Inheritance/Base/ExampleTest.php
Normal file
13
tests/Fixtures/Inheritance/Base/ExampleTest.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Fixtures\Inheritance\Base;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class ExampleTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testExample()
|
||||||
|
{
|
||||||
|
$this->markTestSkipped();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
tests/Fixtures/Inheritance/ExampleTest.php
Normal file
11
tests/Fixtures/Inheritance/ExampleTest.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Fixtures\Inheritance;
|
||||||
|
|
||||||
|
class ExampleTest extends Base\ExampleTest
|
||||||
|
{
|
||||||
|
public function testExample()
|
||||||
|
{
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
tests/Fixtures/phpunit-parallel-inheritance.xml
Normal file
13
tests/Fixtures/phpunit-parallel-inheritance.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="../../vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Parallel Inheritance">
|
||||||
|
<directory suffix="Test.php">./Inheritance</directory>
|
||||||
|
<exclude>./Inheritance/Base</exclude>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
</phpunit>
|
||||||
@ -3,7 +3,9 @@
|
|||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
$run = function () {
|
$run = function () {
|
||||||
$process = new Process(['php', 'bin/pest', '--parallel', '--processes=3', '--exclude-group=integration'], dirname(__DIR__, 2),
|
$process = new Process(
|
||||||
|
array_merge(['php', 'bin/pest', '--parallel', '--processes=3'], func_get_args()),
|
||||||
|
dirname(__DIR__, 2),
|
||||||
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -15,6 +17,12 @@ $run = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test('parallel', function () use ($run) {
|
test('parallel', function () use ($run) {
|
||||||
expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 694 passed (1692 assertions)')
|
expect($run('--exclude-group=integration'))
|
||||||
|
->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 694 passed (1692 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||||
|
|
||||||
|
test('a parallel test can extend another test with same name', function () use ($run) {
|
||||||
|
expect($run('--configuration=tests/Fixtures/phpunit-parallel-inheritance.xml'))
|
||||||
|
->toContain('1 passed');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user