Skip to content

Commit

Permalink
Add --process-isolation support (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk authored Feb 28, 2023
1 parent 87b0b3f commit 429bf1d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ parameters:
path: src/Options.php

-
message: "#^Parameter \\#7 \\$phpunitOptions of class ParaTest\\\\Options constructor expects array\\<non\\-empty\\-string, non\\-empty\\-string\\|true\\>, array\\<'bootstrap'\\|'cache\\-directory'\\|'configuration'\\|'coverage\\-filter'\\|'disallow\\-test\\-output'\\|'dont\\-report\\-useless…'\\|'exclude\\-group'\\|'fail\\-on\\-incomplete'\\|'fail\\-on\\-risky'\\|'fail\\-on\\-skipped'\\|'fail\\-on\\-warning'\\|'filter'\\|'group'\\|'no\\-configuration'\\|'order\\-by'\\|'random\\-order\\-seed'\\|'stop\\-on\\-defect'\\|'stop\\-on\\-error'\\|'stop\\-on\\-incomplete'\\|'stop\\-on\\-risky'\\|'stop\\-on\\-skipped'\\|'stop\\-on\\-warning'\\|'strict\\-coverage'\\|'strict\\-global\\-state', non\\-empty\\-array\\|float\\|int\\<min, \\-1\\>\\|int\\<1, max\\>\\|non\\-falsy\\-string\\|true\\> given\\.$#"
message: "#^Parameter \\#7 \\$phpunitOptions of class ParaTest\\\\Options constructor expects array\\<non\\-empty\\-string, non\\-empty\\-string\\|true\\>, array\\<'bootstrap'\\|'cache\\-directory'\\|'configuration'\\|'coverage\\-filter'\\|'disallow\\-test\\-output'\\|'dont\\-report\\-useless…'\\|'exclude\\-group'\\|'fail\\-on\\-incomplete'\\|'fail\\-on\\-risky'\\|'fail\\-on\\-skipped'\\|'fail\\-on\\-warning'\\|'filter'\\|'group'\\|'no\\-configuration'\\|'order\\-by'\\|'process\\-isolation'\\|'random\\-order\\-seed'\\|'stop\\-on\\-defect'\\|'stop\\-on\\-error'\\|'stop\\-on\\-incomplete'\\|'stop\\-on\\-risky'\\|'stop\\-on\\-skipped'\\|'stop\\-on\\-warning'\\|'strict\\-coverage'\\|'strict\\-global\\-state', non\\-empty\\-array\\|float\\|int\\<min, \\-1\\>\\|int\\<1, max\\>\\|non\\-falsy\\-string\\|true\\> given\\.$#"
count: 1
path: src/Options.php

Expand Down
9 changes: 8 additions & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class Options
'group' => true,
'no-configuration' => true,
'order-by' => true,
'process-isolation' => true,
'random-order-seed' => true,
'stop-on-defect' => true,
'stop-on-error' => true,
Expand Down Expand Up @@ -309,11 +310,17 @@ public static function setInputDefinition(InputDefinition $inputDefinition): voi
'@see PHPUnit guide, chapter: ' . $chapter,
),
new InputOption(
'strict-coverage',
'process-isolation',
null,
InputOption::VALUE_NONE,
'@see PHPUnit guide, chapter: ' . $chapter = 'Execution',
),
new InputOption(
'strict-coverage',
null,
InputOption::VALUE_NONE,
'@see PHPUnit guide, chapter: ' . $chapter,
),
new InputOption(
'strict-global-state',
null,
Expand Down
9 changes: 9 additions & 0 deletions test/Unit/WrapperRunner/WrapperRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,13 @@ public function testHandleCollisionWithSymfonyOutput(): void
$runnerResult = $this->runRunner();
self::assertStringContainsString('<bg=%s>', $runnerResult->output);
}

public function testProcessIsolation(): void
{
$this->bareOptions['path'] = $this->fixture('process_isolation' . DIRECTORY_SEPARATOR . 'FooTest.php');
$this->bareOptions['--process-isolation'] = true;

$runnerResult = $this->runRunner();
self::assertEquals(0, $runnerResult->exitCode);
}
}
26 changes: 26 additions & 0 deletions test/fixtures/process_isolation/FooTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace ParaTest\Tests\fixtures\process_isolation;

use PHPUnit\Framework\TestCase;

use function getenv;
use function putenv;

/** @internal */
final class FooTest extends TestCase
{
public function test1(): void
{
putenv('PROC_ISOLATION=myuniqvalue');

self::assertNotFalse(getenv('PROC_ISOLATION'));
}

public function test2(): void
{
self::assertFalse(getenv('PROC_ISOLATION'));
}
}

0 comments on commit 429bf1d

Please sign in to comment.