Hello!
I've made some improvements to run-tests.php:
1) Autoguessing TEST_PHP_EXECUTABLE and TEST_PHP_CGI_EXECUTABLE if
they're not provided, i.e. assume they have value 'auto'. You can
still pass your own value as usual.
2) Added option -n (use no php.ini) to the shebang line
(#!/usr/bin/php -n) so it would run more reliably on some hosts. My
Ubuntu setup did not have E letter in variables_order (i.e.
variables_order=GPCS) so $_ENV array was empty and some tests were
skipped when they could be run.
3) Some better error handling of wrong paths

So now you can run run-tests.php with just
$ ./run-tests.php ext
instead of
$ TEST_PHP_EXECUTABLE=auto php -n run-tests.php ext

You can also run run-tests.php from sub-dir, it will correctly guess
'auto' as well:
$ cd ext/
$ ../run-tests.php zlib

Please, review this patch and, if there's no objections, I will
prepare 5.4 and 5.3 versions too.

-- 
Regards,
Shein Alexey
Index: run-tests.php
===================================================================
--- run-tests.php       (revision 316410)
+++ run-tests.php       (working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/php -n
 <?php
 /*
    +----------------------------------------------------------------------+
@@ -143,55 +143,40 @@
   $environment["SystemRoot"] = getenv("SystemRoot");
 }
 
-// Don't ever guess at the PHP executable location.
-// Require the explicit specification.
-// Otherwise we could end up testing the wrong file!
+// Try to guess PHP executable location if env variable is not provided, 
assume it to be 'auto'.
 
-$php = null;
-$php_cgi = null;
+$php = getenv('TEST_PHP_EXECUTABLE') ? getenv('TEST_PHP_EXECUTABLE') : 'auto';
+$php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE') ? 
getenv('TEST_PHP_CGI_EXECUTABLE') : 'auto';
 
-if (getenv('TEST_PHP_EXECUTABLE')) {
-       $php = getenv('TEST_PHP_EXECUTABLE');
-
-       if ($php=='auto') {
-               $php = $cwd . '/sapi/cli/php';
-               putenv("TEST_PHP_EXECUTABLE=$php");
-
-               if (!getenv('TEST_PHP_CGI_EXECUTABLE')) {
-                       $php_cgi = $cwd . '/sapi/cgi/php-cgi';
-
-                       if (file_exists($php_cgi)) {
-                               putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi");
-                       } else {
-                               $php_cgi = null;
-                       }
-               }
-       }
-       $environment['TEST_PHP_EXECUTABLE'] = $php;
+if ($php == 'auto') {
+       $php = realpath(__DIR__ . '/sapi/cli/php');
+       putenv("TEST_PHP_EXECUTABLE=$php");
 }
+$environment['TEST_PHP_EXECUTABLE'] = $php;
 
-if (getenv('TEST_PHP_CGI_EXECUTABLE')) {
-       $php_cgi = getenv('TEST_PHP_CGI_EXECUTABLE');
-
-       if ($php_cgi=='auto') {
-               $php_cgi = $cwd . '/sapi/cgi/php-cgi';
-               putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi");
-       }
-
-       $environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi;
+if ($php_cgi == 'auto') {
+       $php_cgi = realpath(__DIR__ . '/sapi/cgi/php-cgi');
+       putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi");
 }
+$environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi;
 
 function verify_config()
 {
-       global $php;
+       global $php, $php_cgi;
 
-       if (empty($php) || !file_exists($php)) {
+       if (empty($php) || !is_file($php)) {
                error('environment variable TEST_PHP_EXECUTABLE must be set to 
specify PHP executable!');
        }
 
        if (function_exists('is_executable') && !is_executable($php)) {
                error("invalid PHP executable specified by TEST_PHP_EXECUTABLE  
= $php");
        }
+
+       if (!empty($php_cgi)) {
+               if (!is_file($php_cgi) || (function_exists('is_executable') && 
!is_executable($php_cgi))) {
+                       error("invalid PHP-CGI executable specified by 
TEST_PHP_CGI_EXECUTABLE = $php_cgi");
+               }
+       }
 }
 
 if (getenv('TEST_PHP_LOG_FORMAT')) {
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to