mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
- Run ext/* tests only for those modules that are actually compiled
into the php binary. (faster) - Skip search of .phpt files if they are passed as parameters
This commit is contained in:
parent
0662a009db
commit
fc721174c8
114
run-tests.php
114
run-tests.php
@ -44,7 +44,7 @@ ob_implicit_flush();
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if (ini_get('safe_mode')) {
|
||||
echo <<<SAFE_MODE_WARNING
|
||||
echo <<< SAFE_MODE_WARNING
|
||||
|
||||
+-----------------------------------------------------------+
|
||||
| ! WARNING ! |
|
||||
@ -62,25 +62,25 @@ SAFE_MODE_WARNING;
|
||||
// Require the explicit specification.
|
||||
// Otherwise we could end up testing the wrong file!
|
||||
|
||||
if(isset($_ENV['TEST_PHP_EXECUTABLE'])) {
|
||||
if (isset($_ENV['TEST_PHP_EXECUTABLE'])) {
|
||||
$php = $_ENV['TEST_PHP_EXECUTABLE'];
|
||||
} else {
|
||||
error("environment variable TEST_PHP_EXECUTABLE must be set to specify PHP executable!");
|
||||
}
|
||||
|
||||
if(isset($_ENV['TEST_PHP_LOG_FORMAT'])) {
|
||||
if (isset($_ENV['TEST_PHP_LOG_FORMAT'])) {
|
||||
$log_format = strtoupper($_ENV['TEST_PHP_LOG_FORMAT']);
|
||||
} else {
|
||||
$log_format = 'LEOD';
|
||||
}
|
||||
|
||||
if(!@is_executable($php)) {
|
||||
if (!@is_executable($php)) {
|
||||
error("invalid PHP executable specified by TEST_PHP_EXECUTABLE = " . $php);
|
||||
}
|
||||
|
||||
// Check whether a detailed log is wanted.
|
||||
|
||||
if(isset($_ENV['TEST_PHP_DETAILED'])) {
|
||||
if (isset($_ENV['TEST_PHP_DETAILED'])) {
|
||||
define('DETAILED', $_ENV['TEST_PHP_DETAILED']);
|
||||
} else {
|
||||
define('DETAILED', 0);
|
||||
@ -103,7 +103,7 @@ INI wanted : " . realpath('php.ini-dist') . "
|
||||
// Make sure we are using the proper php.ini.
|
||||
|
||||
$php_ini = realpath("php.ini-dist");
|
||||
if(realpath(get_cfg_var('cfg_file_path')) != $php_ini) {
|
||||
if (realpath(get_cfg_var('cfg_file_path')) != $php_ini) {
|
||||
error("php.ini-dist was not used!");
|
||||
}
|
||||
$php .= " -c $php_ini";
|
||||
@ -115,55 +115,14 @@ $test_files = array();
|
||||
$test_results = array();
|
||||
|
||||
// If parameters given assume they represent selected tests to run.
|
||||
if (isset($argc) && $argc>1) {
|
||||
if (isset($argc) && $argc > 1) {
|
||||
for ($i=1; $i<$argc; $i++) {
|
||||
$testfile = realpath($argv[$i]);
|
||||
$test_to_run[$testfile] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Compile a list of all test files (*.phpt).
|
||||
$test_files = array();
|
||||
$module_of_test = array();
|
||||
find_files(getcwd());
|
||||
|
||||
function find_files($dir) {
|
||||
global $test_files, $module_of_test;
|
||||
|
||||
/* FIXME: this messes up if you unpack PHP in /ext/pear :) */
|
||||
if (ereg('/ext/([^/]+)/',"$dir/",$r)) {
|
||||
$module = $r[1];
|
||||
} else if (ereg('/pear/',"$dir/")) {
|
||||
$module = 'pear';
|
||||
} else {
|
||||
$module = '';
|
||||
}
|
||||
|
||||
$o = opendir($dir) or error("cannot open directory: $dir");
|
||||
while (($name = readdir($o))!==false) {
|
||||
if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', 'CVS'))) {
|
||||
find_files("{$dir}/{$name}");
|
||||
}
|
||||
|
||||
// Cleanup any left-over tmp files from last run.
|
||||
if (substr($name, -4)=='.tmp') {
|
||||
@unlink("$dir/$name");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise we're only interested in *.phpt files.
|
||||
if (substr($name, -5)=='.phpt') {
|
||||
$testfile = realpath("{$dir}/{$name}");
|
||||
$test_files[] = $testfile;
|
||||
// $module_of_test[$testfile] = $module;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($o);
|
||||
}
|
||||
|
||||
// Run only selected tests, if specified.
|
||||
if (count($test_to_run)) {
|
||||
// Run selected tests.
|
||||
if (count($test_to_run)) {
|
||||
echo "Running selected tests.\n";
|
||||
foreach($test_to_run AS $name=>$runnable) {
|
||||
echo "test: $name runnable: $runnable\n";
|
||||
@ -172,6 +131,49 @@ if (count($test_to_run)) {
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Compile a list of all test files (*.phpt).
|
||||
$test_files = array();
|
||||
$exts_to_test = get_loaded_extensions();
|
||||
sort($exts_to_test);
|
||||
$extra_dirs = array('pear', 'tests');
|
||||
$cwd=getcwd();
|
||||
|
||||
// First get list of test files in ext/
|
||||
foreach ($exts_to_test as $dir) {
|
||||
find_files("{$cwd}/ext/{$dir}");
|
||||
}
|
||||
|
||||
// Then the rest
|
||||
foreach ($extra_dirs as $dir) {
|
||||
find_files("{$cwd}/{$dir}");
|
||||
}
|
||||
|
||||
function find_files($dir)
|
||||
{
|
||||
global $test_files;
|
||||
|
||||
$o = opendir($dir) or error("cannot open directory: $dir");
|
||||
while (($name = readdir($o)) !== false) {
|
||||
if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', 'CVS'))) {
|
||||
find_files("{$dir}/{$name}");
|
||||
}
|
||||
|
||||
// Cleanup any left-over tmp files from last run.
|
||||
if (substr($name, -4) == '.tmp') {
|
||||
@unlink("$dir/$name");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise we're only interested in *.phpt files.
|
||||
if (substr($name, -5) == '.phpt') {
|
||||
$testfile = realpath("{$dir}/{$name}");
|
||||
$test_files[] = $testfile;
|
||||
}
|
||||
}
|
||||
closedir($o);
|
||||
}
|
||||
|
||||
sort($test_files);
|
||||
@ -231,9 +233,9 @@ Time taken : " . sprintf("%4d seconds", $end_time - $start_time) . "
|
||||
// Write the given text to a temporary file, and return the filename.
|
||||
//
|
||||
|
||||
function save_text($filename,$text) {
|
||||
$fp = @fopen($filename,'w')
|
||||
or error("Cannot open file '" . $filename . "' (save_text)");
|
||||
function save_text($filename,$text)
|
||||
{
|
||||
$fp = @fopen($filename,'w') or error("Cannot open file '" . $filename . "' (save_text)");
|
||||
fwrite($fp,$text);
|
||||
fclose($fp);
|
||||
if (1 < DETAILED) echo "
|
||||
@ -464,7 +466,8 @@ $output
|
||||
return 'FAILED';
|
||||
}
|
||||
|
||||
function generate_diff($wanted,$output) {
|
||||
function generate_diff($wanted,$output)
|
||||
{
|
||||
$w = explode("\n", $wanted);
|
||||
$o = explode("\n", $output);
|
||||
$w1 = array_diff($w,$o);
|
||||
@ -478,7 +481,8 @@ function generate_diff($wanted,$output) {
|
||||
return implode("\r\n", $diff);
|
||||
}
|
||||
|
||||
function error($message) {
|
||||
function error($message)
|
||||
{
|
||||
echo "ERROR: {$message}\n";
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user