Skip to content

Commit 0575997

Browse files
Simplify usage of php-invoker
2 parents b0e8fce + 3f4d3d7 commit 0575997

File tree

6 files changed

+8
-88
lines changed

6 files changed

+8
-88
lines changed

build.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,13 @@
3434
</target>
3535

3636
<target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed,validate-composer-json" description="Install dependencies with Composer">
37-
<copy file="${basedir}/composer.json" tofile="${basedir}/build/tmp/composer.json"/>
38-
39-
<exec executable="${basedir}/tools/composer" taskname="composer">
40-
<arg value="require"/>
41-
<arg value="--no-update"/>
42-
<arg value="phpunit/php-invoker:^2.0"/>
43-
</exec>
44-
4537
<exec executable="${basedir}/tools/composer" taskname="composer">
4638
<arg value="update"/>
4739
<arg value="--no-interaction"/>
4840
<arg value="--no-progress"/>
4941
<arg value="--no-ansi"/>
5042
<arg value="--no-suggest"/>
5143
</exec>
52-
53-
<move file="${basedir}/build/tmp/composer.json" tofile="${basedir}/composer.json"/>
5444
</target>
5545

5646
<target name="check-dependencies" description="Performs check for outdated dependencies">

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"support": {
2020
"issues": "https://github.com/sebastianbergmann/phpunit/issues"
2121
},
22+
"minimum-stability": "dev",
2223
"prefer-stable": true,
2324
"require": {
2425
"php": "^7.3",
@@ -35,6 +36,7 @@
3536
"phpspec/prophecy": "^1.8.1",
3637
"phpunit/php-code-coverage": "^7.0.7",
3738
"phpunit/php-file-iterator": "^2.0.2",
39+
"phpunit/php-invoker": "^3.0",
3840
"phpunit/php-text-template": "^1.2.1",
3941
"phpunit/php-timer": "^2.1.2",
4042
"sebastian/comparator": "^3.0.2",
@@ -58,7 +60,6 @@
5860
"sort-packages": true
5961
},
6062
"suggest": {
61-
"phpunit/php-invoker": "^2.0.0",
6263
"ext-soap": "*",
6364
"ext-xdebug": "*"
6465
},

src/Framework/TestResult.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,12 @@ public function run(Test $test): void
659659
Timer::start();
660660

661661
try {
662+
$invoker = new Invoker;
663+
662664
if (!$test instanceof WarningTestCase &&
663665
$this->enforceTimeLimit &&
664666
($this->defaultTimeLimit || $test->getSize() != \PHPUnit\Util\Test::UNKNOWN) &&
665-
\extension_loaded('pcntl') && \class_exists(Invoker::class)) {
667+
$invoker->canInvokeWithTimeout()) {
666668
switch ($test->getSize()) {
667669
case \PHPUnit\Util\Test::SMALL:
668670
$_timeout = $this->timeoutForSmallTests;
@@ -685,7 +687,6 @@ public function run(Test $test): void
685687
break;
686688
}
687689

688-
$invoker = new Invoker;
689690
$invoker->invoke([$test, 'runBare'], [], $_timeout);
690691
} else {
691692
$test->runBare();

src/TextUI/TestRunner.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,10 @@ public function doRun(Test $suite, array $arguments = [], bool $exit = true): Te
592592
$result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
593593
$result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']);
594594

595-
if ($arguments['enforceTimeLimit'] === true) {
596-
if (!\class_exists(Invoker::class)) {
597-
$this->writeMessage('Error', 'Package phpunit/php-invoker is required for enforcing time limits');
598-
}
599-
600-
if (!\extension_loaded('pcntl') || \strpos(\ini_get('disable_functions'), 'pcntl') !== false) {
601-
$this->writeMessage('Error', 'PHP extension pcntl is required for enforcing time limits');
602-
}
595+
if ($arguments['enforceTimeLimit'] === true && !(new Invoker)->canInvokeWithTimeout()) {
596+
$this->writeMessage('Error', 'PHP extension pcntl is required for enforcing time limits');
603597
}
598+
604599
$result->enforceTimeLimit($arguments['enforceTimeLimit']);
605600
$result->setDefaultTimeLimit($arguments['defaultTimeLimit']);
606601
$result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);

tests/end-to-end/regression/GitHub/2085-enforce-time-limit-options-via-config-without-invoker.phpt

Lines changed: 0 additions & 33 deletions
This file was deleted.

tests/end-to-end/regression/GitHub/2085-without-invoker.phpt

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)