From: foobar Date: Wed, 2 Oct 2002 01:52:25 +0000 (+0000) Subject: - Run ext/* tests only for those modules that are actually compiled X-Git-Tag: MODERN_SYMMETRIC_SESSION_BEHAVIOUR_20021003~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc721174c830d5c87b8fc2c08c294ae7db750ee5;p=php - 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 --- diff --git a/run-tests.php b/run-tests.php index 7a1f21f3db..e1a220aaf1 100755 --- a/run-tests.php +++ b/run-tests.php @@ -44,7 +44,7 @@ ob_implicit_flush(); error_reporting(E_ALL); if (ini_get('safe_mode')) { - echo <<1) { +if (isset($argc) && $argc > 1) { for ($i=1; $i<$argc; $i++) { $testfile = realpath($argv[$i]); $test_to_run[$testfile] = 1; } + + // 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"; + if ($runnable) { + $test_results[$name] = run_test($php,$name); + } + } + exit(0); + } } // 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 = ''; - } +$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) { + 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') { + if (substr($name, -4) == '.tmp') { @unlink("$dir/$name"); continue; } // Otherwise we're only interested in *.phpt files. - if (substr($name, -5)=='.phpt') { + 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)) { - echo "Running selected tests.\n"; - foreach($test_to_run AS $name=>$runnable) { - echo "test: $name runnable: $runnable\n"; - if ($runnable) { - $test_results[$name] = run_test($php,$name); - } - } - exit(0); -} - sort($test_files); $start_time = time(); @@ -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); }