Skip to content

Commit 9b37b06

Browse files
Merge branch '8.5' into 9.6
2 parents a122c2e + 3291172 commit 9b37b06

File tree

6 files changed

+50
-23
lines changed

6 files changed

+50
-23
lines changed

ChangeLog-9.6.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 9.6 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [9.6.13] - 2023-MM-DD
6+
7+
### Changed
8+
9+
* The child processes used for process isolation now use temporary files to communicate their result to the parent process
10+
511
## [9.6.12] - 2023-09-12
612

713
### Changed
@@ -89,6 +95,7 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil
8995
* [#5064](https://github.com/sebastianbergmann/phpunit/issues/5064): Deprecate `PHPUnit\Framework\TestCase::getMockClass()`
9096
* [#5132](https://github.com/sebastianbergmann/phpunit/issues/5132): Deprecate `Test` suffix for abstract test case classes
9197

98+
[9.6.13]: https://github.com/sebastianbergmann/phpunit/compare/9.6.12...9.6
9299
[9.6.12]: https://github.com/sebastianbergmann/phpunit/compare/9.6.11...9.6.12
93100
[9.6.11]: https://github.com/sebastianbergmann/phpunit/compare/9.6.10...9.6.11
94101
[9.6.10]: https://github.com/sebastianbergmann/phpunit/compare/9.6.9...9.6.10

src/Framework/TestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
use function sprintf;
6161
use function strpos;
6262
use function substr;
63+
use function sys_get_temp_dir;
64+
use function tempnam;
6365
use function trim;
6466
use function var_export;
6567
use DeepCopy\DeepCopy;
@@ -924,6 +926,7 @@ public function run(TestResult $result = null): TestResult
924926
$codeCoverageCacheDirectory = "'." . $codeCoverageCacheDirectory . ".'";
925927

926928
$configurationFilePath = $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] ?? '';
929+
$processResultFile = tempnam(sys_get_temp_dir(), 'phpunit_');
927930

928931
$var = [
929932
'composerAutoload' => $composerAutoload,
@@ -950,6 +953,7 @@ public function run(TestResult $result = null): TestResult
950953
'codeCoverageFilter' => $codeCoverageFilter,
951954
'configurationFilePath' => $configurationFilePath,
952955
'name' => $this->getName(false),
956+
'processResultFile' => $processResultFile,
953957
];
954958

955959
if (!$runEntireClass) {
@@ -959,7 +963,7 @@ public function run(TestResult $result = null): TestResult
959963
$template->setVar($var);
960964

961965
$php = AbstractPhpProcess::factory();
962-
$php->runTestJob($template->render(), $this, $result);
966+
$php->runTestJob($template->render(), $this, $result, $processResultFile);
963967
} else {
964968
$result->run($this);
965969
}

src/Util/PHP/AbstractPhpProcess.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use function array_merge;
1616
use function assert;
1717
use function escapeshellarg;
18+
use function file_exists;
19+
use function file_get_contents;
1820
use function ini_get_all;
1921
use function restore_error_handler;
2022
use function set_error_handler;
@@ -24,6 +26,7 @@
2426
use function strrpos;
2527
use function substr;
2628
use function trim;
29+
use function unlink;
2730
use function unserialize;
2831
use __PHP_Incomplete_Class;
2932
use ErrorException;
@@ -174,16 +177,23 @@ public function getTimeout(): int
174177
*
175178
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
176179
*/
177-
public function runTestJob(string $job, Test $test, TestResult $result): void
180+
public function runTestJob(string $job, Test $test, TestResult $result, string $processResultFile): void
178181
{
179182
$result->startTest($test);
180183

181-
$_result = $this->runJob($job);
184+
$processResult = '';
185+
$_result = $this->runJob($job);
186+
187+
if (file_exists($processResultFile)) {
188+
$processResult = file_get_contents($processResultFile);
189+
190+
@unlink($processResultFile);
191+
}
182192

183193
$this->processChildResult(
184194
$test,
185195
$result,
186-
$_result['stdout'],
196+
$processResult,
187197
$_result['stderr'],
188198
);
189199
}

src/Util/PHP/Template/TestCaseClass.tpl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function __phpunit_run_isolated_test()
5858

5959
$test = new {className}('{name}', unserialize('{data}'), '{dataName}');
6060
$test->setDependencyInput(unserialize('{dependencyInput}'));
61-
$test->setInIsolation(TRUE);
61+
$test->setInIsolation(true);
6262

6363
ob_end_clean();
6464
$test->run($result);
@@ -68,6 +68,7 @@ function __phpunit_run_isolated_test()
6868
}
6969

7070
ini_set('xdebug.scream', '0');
71+
7172
@rewind(STDOUT); /* @ as not every STDOUT target stream is rewindable */
7273
if ($stdout = @stream_get_contents(STDOUT)) {
7374
$output = $stdout . $output;
@@ -78,13 +79,16 @@ function __phpunit_run_isolated_test()
7879
}
7980
}
8081

81-
print serialize(
82-
[
83-
'testResult' => $test->getResult(),
84-
'numAssertions' => $test->getNumAssertions(),
85-
'result' => $result,
86-
'output' => $output
87-
]
82+
file_put_contents(
83+
'{processResultFile}',
84+
serialize(
85+
[
86+
'testResult' => $test->getResult(),
87+
'numAssertions' => $test->getNumAssertions(),
88+
'result' => $result,
89+
'output' => $output
90+
]
91+
)
8892
);
8993
}
9094

src/Util/PHP/Template/TestCaseMethod.tpl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function __phpunit_run_isolated_test()
7171
}
7272

7373
ini_set('xdebug.scream', '0');
74+
7475
@rewind(STDOUT); /* @ as not every STDOUT target stream is rewindable */
7576
if ($stdout = @stream_get_contents(STDOUT)) {
7677
$output = $stdout . $output;
@@ -81,13 +82,16 @@ function __phpunit_run_isolated_test()
8182
}
8283
}
8384

84-
print serialize(
85-
[
86-
'testResult' => $test->getResult(),
87-
'numAssertions' => $test->getNumAssertions(),
88-
'result' => $result,
89-
'output' => $output
90-
]
85+
file_put_contents(
86+
'{processResultFile}',
87+
serialize(
88+
[
89+
'testResult' => $test->getResult(),
90+
'numAssertions' => $test->getNumAssertions(),
91+
'result' => $result,
92+
'output' => $output
93+
]
94+
)
9195
);
9296
}
9397

tests/end-to-end/regression/1348.phpt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
--TEST--
22
https://github.com/sebastianbergmann/phpunit/issues/1348
3-
--XFAIL--
4-
https://github.com/sebastianbergmann/phpunit/issues/5356
53
--SKIPIF--
64
<?php declare(strict_types=1);
7-
if (defined('HHVM_VERSION') || defined('PHPDBG_VERSION')) {
8-
print 'skip: PHP runtime required';
5+
if (defined('STDOUT')) {
6+
print 'skip: PHP < 8.3 required';
97
}
108
--FILE--
119
<?php declare(strict_types=1);

0 commit comments

Comments
 (0)