Skip to content

Commit 9320731

Browse files
staabmsebastianbergmann
authored andcommitted
Remove windows stdout workarounds
1 parent 19c41a3 commit 9320731

File tree

2 files changed

+3
-56
lines changed

2 files changed

+3
-56
lines changed

src/Util/PHP/DefaultPhpProcess.php

+3-36
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
use function is_array;
1717
use function is_resource;
1818
use function proc_close;
19-
use function proc_get_status;
2019
use function proc_open;
21-
use function rewind;
2220
use function stream_get_contents;
2321
use function sys_get_temp_dir;
2422
use function tempnam;
25-
use function time_nanosleep;
2623
use function unlink;
2724
use PHPUnit\Framework\Exception;
2825

@@ -57,14 +54,6 @@ public function runJob(string $job, array $settings = []): array
5754
return $this->runProcess($job, $settings);
5855
}
5956

60-
/**
61-
* Returns an array of file handles to be used in place of pipes.
62-
*/
63-
protected function getHandles(): array
64-
{
65-
return [];
66-
}
67-
6857
/**
6958
* Handles creating the child process and returning the STDOUT and STDERR.
7059
*
@@ -75,8 +64,6 @@ protected function getHandles(): array
7564
*/
7665
protected function runProcess(string $job, array $settings): array
7766
{
78-
$handles = $this->getHandles();
79-
8067
$env = null;
8168

8269
if ($this->env) {
@@ -92,9 +79,9 @@ protected function runProcess(string $job, array $settings): array
9279
}
9380

9481
$pipeSpec = [
95-
0 => $handles[0] ?? ['pipe', 'r'],
96-
1 => $handles[1] ?? ['pipe', 'w'],
97-
2 => $handles[2] ?? ['pipe', 'w'],
82+
0 => ['pipe', 'r'],
83+
1 => ['pipe', 'w'],
84+
2 => ['pipe', 'w'],
9885
];
9986

10087
if ($this->stderrRedirection) {
@@ -121,10 +108,6 @@ protected function runProcess(string $job, array $settings): array
121108

122109
fclose($pipes[0]);
123110

124-
while (proc_get_status($process)['running'] === true) {
125-
time_nanosleep(0, 100000);
126-
}
127-
128111
$stderr = $stdout = '';
129112

130113
if (isset($pipes[1])) {
@@ -139,22 +122,6 @@ protected function runProcess(string $job, array $settings): array
139122
fclose($pipes[2]);
140123
}
141124

142-
if (isset($handles[1])) {
143-
rewind($handles[1]);
144-
145-
$stdout = stream_get_contents($handles[1]);
146-
147-
fclose($handles[1]);
148-
}
149-
150-
if (isset($handles[2])) {
151-
rewind($handles[2]);
152-
153-
$stderr = stream_get_contents($handles[2]);
154-
155-
fclose($handles[2]);
156-
}
157-
158125
proc_close($process);
159126

160127
$this->cleanup();

src/Util/PHP/WindowsPhpProcess.php

-20
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,13 @@
99
*/
1010
namespace PHPUnit\Util\PHP;
1111

12-
use function tmpfile;
13-
use PHPUnit\Framework\Exception;
14-
1512
/**
1613
* @internal This class is not covered by the backward compatibility promise for PHPUnit
1714
*
1815
* @see https://bugs.php.net/bug.php?id=51800
1916
*/
2017
final class WindowsPhpProcess extends DefaultPhpProcess
2118
{
22-
/**
23-
* @throws Exception
24-
* @throws PhpProcessException
25-
*/
26-
protected function getHandles(): array
27-
{
28-
if (false === $stdout_handle = tmpfile()) {
29-
throw new PhpProcessException(
30-
'A temporary file could not be created; verify that your TEMP environment variable is writable',
31-
);
32-
}
33-
34-
return [
35-
1 => $stdout_handle,
36-
];
37-
}
38-
3919
protected function useTemporaryFile(): bool
4020
{
4121
return false;

0 commit comments

Comments
 (0)