Skip to content

Commit 688ba01

Browse files
committed
Fix test, now can run on windows
1 parent 6671223 commit 688ba01

10 files changed

Lines changed: 23 additions & 43 deletions

sapi/cli/tests/php_cli_server.inc

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
define ("PHP_CLI_SERVER_ADDRESS", "localhost:8964");
33

44
function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE) {
5-
$php_executable = getenv('TEST_PHP_EXECUTABLE');
5+
$php_executable = getenv('TEST_PHP_EXECUTABLE');
66
$doc_root = __DIR__;
77
$router = "index.php";
88
file_put_contents($doc_root . '/' . $router, '<?php ' . $code . ' ?>');
@@ -13,21 +13,31 @@ function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE)
1313
2 => STDERR,
1414
);
1515

16-
$cmd = "exec {$php_executable} -t {$doc_root} -S " . PHP_CLI_SERVER_ADDRESS;
16+
if (substr(PHP_OS, 0, 3) == 'WIN') {
17+
$cmd = "{$php_executable} -t {$doc_root} -S " . PHP_CLI_SERVER_ADDRESS;
18+
if (!$no_router) {
19+
$cmd .= " {$router}";
20+
}
1721

18-
if (!$no_router) {
19-
$cmd .= " {$router}";
20-
}
22+
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
23+
} else {
24+
$cmd = "exec {$php_executable} -t {$doc_root} -S " . PHP_CLI_SERVER_ADDRESS;
25+
if (!$no_router) {
26+
$cmd .= " {$router}";
27+
}
28+
$cmd .= " 2>/dev/null";
2129

22-
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
30+
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
31+
}
2332

24-
register_shutdown_function(
25-
function($handle) use($router) {
26-
proc_terminate($handle);
27-
@unlink(__DIR__ . "/{$router}");
28-
},
29-
$handle
30-
);
33+
register_shutdown_function(
34+
function($handle) use($router) {
35+
proc_terminate($handle);
36+
@unlink(__DIR__ . "/{$router}");
37+
},
38+
$handle
39+
);
3140
usleep(50000);
3241
}
3342
?>
43+

sapi/cli/tests/php_cli_server_001.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ allow_url_fopen=1
55
--SKIPIF--
66
<?php
77
include "skipif.inc";
8-
if (substr(PHP_OS, 0, 3) == 'WIN') {
9-
die ("skip not for Windows");
10-
}
118
?>
129
--FILE--
1310
<?php

sapi/cli/tests/php_cli_server_002.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ allow_url_fopen=1
55
--SKIPIF--
66
<?php
77
include "skipif.inc";
8-
if (substr(PHP_OS, 0, 3) == 'WIN') {
9-
die ("skip not for Windows");
10-
}
118
?>
129
--FILE--
1310
<?php

sapi/cli/tests/php_cli_server_003.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ allow_url_fopen=1
55
--SKIPIF--
66
<?php
77
include "skipif.inc";
8-
if (substr(PHP_OS, 0, 3) == 'WIN') {
9-
die ("skip not for Windows");
10-
}
118
?>
129
--FILE--
1310
<?php

sapi/cli/tests/php_cli_server_004.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ allow_url_fopen=1
55
--SKIPIF--
66
<?php
77
include "skipif.inc";
8-
if (substr(PHP_OS, 0, 3) == 'WIN') {
9-
die ("skip not for Windows");
10-
}
118
?>
129
--FILE--
1310
<?php

sapi/cli/tests/php_cli_server_005.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ Post a file
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6-
if (substr(PHP_OS, 0, 3) == 'WIN') {
7-
die ("skip not for Windows");
8-
}
96
?>
107
--FILE--
118
<?php

sapi/cli/tests/php_cli_server_006.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ Bug #55755 (SegFault when outputting header WWW-Authenticate)
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6-
if (substr(PHP_OS, 0, 3) == 'WIN') {
7-
die ("skip not for Windows");
8-
}
96
?>
107
--FILE--
118
<?php

sapi/cli/tests/php_cli_server_007.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ Bug #55758 (Digest Authenticate missed in 5.4)
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6-
if (substr(PHP_OS, 0, 3) == 'WIN') {
7-
die ("skip not for Windows");
8-
}
96
?>
107
--FILE--
118
<?php

sapi/cli/tests/php_cli_server_008.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ SERVER_PROTOCOL header availability
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6-
if (substr(PHP_OS, 0, 3) == 'WIN') {
7-
die ("skip not for Windows");
8-
}
96
?>
107
--FILE--
118
<?php

sapi/cli/tests/php_cli_server_009.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ now could serve correctly with request_uri "index.php" and PATH_INFO "/foo/bar/"
66
--SKIPIF--
77
<?php
88
include "skipif.inc";
9-
if (substr(PHP_OS, 0, 3) == 'WIN') {
10-
die ("skip not for Windows");
11-
}
129
?>
1310
--FILE--
1411
<?php
@@ -79,21 +76,18 @@ HEADER
7976
fclose($fp);
8077
?>
8178
--EXPECTF--
82-
[%s] %s
8379
HTTP/1.1 200 OK
8480
Host: %s
8581
Connection: closed
8682
X-Powered-By: PHP/%s-dev
8783
Content-type: text/html
8884

8985
string(8) "/foo/bar"
90-
[%s] %s
9186
HTTP/1.0 200 OK
9287
Host: %s
9388
Connection: closed
9489
X-Powered-By: PHP/%s-dev
9590
Content-type: text/html
9691

9792
string(9) "/foo/bar/"
98-
[%s] %s
9993
HTTP/1.0 404 Not Found

0 commit comments

Comments
 (0)