Skip to content

Commit aff99f5

Browse files
committed
Support sapi/cli/tests/017.phpt on Windows, too
`escapeshellarg()` is pretty useless on Windows, and there is no way to support multiple lines (i.e. line breaks). Thus, we use `proc_open()` instead of `shell_exec()`. We also remove some apparently superfluous empty lines from the test expectation; that seems to match libedit behavior on Linux. Closes GH-9474.
1 parent ce9077d commit aff99f5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

sapi/cli/tests/017.phpt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ include "skipif.inc";
88
if (readline_info('done') !== NULL) {
99
die ("skip need readline support using libedit");
1010
}
11-
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
12-
die('skip not for Windows');
13-
}
1411
?>
1512
--FILE--
1613
<?php
1714
$php = getenv('TEST_PHP_EXECUTABLE');
15+
$ini = getenv('TEST_PHP_EXTRA_ARGS');
16+
$descriptorspec = [['pipe', 'r'], STDOUT, STDERR];
1817

1918
$codes = array();
2019

@@ -55,8 +54,10 @@ EOT;
5554

5655
foreach ($codes as $key => $code) {
5756
echo "\n--------------\nSnippet no. $key:\n--------------\n";
58-
$code = escapeshellarg($code);
59-
echo `echo $code | "$php" -a`, "\n";
57+
$proc = proc_open("$php $ini -a", $descriptorspec, $pipes);
58+
fwrite($pipes[0], $code);
59+
fclose($pipes[0]);
60+
proc_close($proc);
6061
}
6162

6263
echo "\nDone\n";
@@ -69,7 +70,6 @@ Interactive shell
6970

7071
Hello world
7172

72-
7373
--------------
7474
Snippet no. 2:
7575
--------------
@@ -79,7 +79,6 @@ multine
7979
single
8080
quote
8181

82-
8382
--------------
8483
Snippet no. 3:
8584
--------------
@@ -90,15 +89,13 @@ comes
9089
the
9190
doc
9291

93-
9492
--------------
9593
Snippet no. 4:
9694
--------------
9795
Interactive shell
9896

9997
Done
10098

101-
10299
--------------
103100
Snippet no. 5:
104101
--------------
@@ -107,5 +104,4 @@ Interactive shell
107104

108105
Parse error: Unmatched ')' in php shell code on line 1
109106

110-
111107
Done

0 commit comments

Comments
 (0)