summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-07-24 17:44:16 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-07-24 17:44:16 +0000
commit64d642188557c6ca67c7120cb3233906a73fca86 (patch)
treed42d0c3acd1ab9bc4f8dd1433094226610ab4190 /run-tests.php
parent3fbe69f49aae47fa6e624fb9e8dedbf29cd0f88f (diff)
downloadphp-git-64d642188557c6ca67c7120cb3233906a73fca86.tar.gz
When encountering a test that users GET/POST make run-tests.php use CGI
sapi if it is avaliable. If CLI sapi is not avaliable print a clear error when make test is executed.
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/run-tests.php b/run-tests.php
index e96ddcbf18..a6a226f9ca 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -117,7 +117,7 @@ if (getenv('TEST_PHP_EXECUTABLE')) {
putenv("TEST_PHP_EXECUTABLE=$php");
}
}
-if (!file_exists($php)) {
+if (empty($php) || !file_exists($php)) {
error("environment variable TEST_PHP_EXECUTABLE must be set to specify PHP executable!");
}
@@ -665,6 +665,14 @@ TEST $file
}
fclose($fp);
+ /* For GET/POST tests, check if cgi sapi is avaliable and if it is, use it. */
+ if ((!empty($section_text['GET']) || !empty($section_text['POST']))) {
+ if (file_exists("./sapi/cgi/php")) {
+ $old_php = $php;
+ $php = realpath("./sapi/cgi/php") . ' -C ';
+ }
+ }
+
$shortname = str_replace($cwd.'/', '', $file);
$tested = trim($section_text['TEST'])." [$shortname]";
@@ -708,6 +716,9 @@ TEST $file
} else {
echo "\n";
}
+ if (isset($old_php)) {
+ $php = $old_php;
+ }
return 'SKIPPED';
}
if (eregi("^info", trim($output))) {
@@ -795,6 +806,11 @@ COMMAND $cmd
$output = trim($out);
$output = preg_replace('/\r\n/',"\n",$output);
+ /* when using CGI, strip the headers from the output */
+ if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) {
+ $output = substr($output, ($pos + 2));
+ }
+
if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
if (isset($section_text['EXPECTF'])) {
$wanted = trim($section_text['EXPECTF']);
@@ -821,6 +837,9 @@ COMMAND $cmd
if (preg_match("/^$wanted_re\$/s", $output)) {
@unlink($tmp_file);
echo "PASS $tested\n";
+ if (isset($old_php)) {
+ $php = $old_php;
+ }
return 'PASSED';
}
@@ -832,6 +851,9 @@ COMMAND $cmd
if ($ok) {
@unlink($tmp_file);
echo "PASS $tested\n";
+ if (isset($old_php)) {
+ $php = $old_php;
+ }
return 'PASSED';
}
}
@@ -890,6 +912,10 @@ $output
error_report($file,$logname,$tested);
}
+ if (isset($old_php)) {
+ $php = $old_php;
+ }
+
return $warn ? 'WARNED' : 'FAILED';
}