Browse Source

ws fixes

migration/unlabaled-1.29.2
foobar 23 years ago
parent
commit
9a010becf1
  1. 60
      run-tests.php

60
run-tests.php

@ -39,6 +39,7 @@
* - do not test PEAR components if base class and/or component class cannot be instanciated
*/
$cwd = getcwd();
set_time_limit(0);
ob_implicit_flush();
error_reporting(E_ALL);
@ -90,7 +91,7 @@ if (isset($_ENV['TEST_PHP_DETAILED'])) {
echo "
=====================================================================
CWD : " . getcwd() . "
CWD : $cwd
PHP : $php
PHP_SAPI : " . PHP_SAPI . "
PHP_VERSION : " . PHP_VERSION . "
@ -143,24 +144,23 @@ $exts_skipped = 0;
$ignored_by_ext = 0;
sort($exts_to_test);
$test_dirs = array('tests', 'pear', 'ext');
$cwd=getcwd();
foreach ($test_dirs as $dir) {
find_files("{$cwd}/{$dir}", $dir=='ext');
find_files("{$cwd}/{$dir}", ($dir == 'ext'));
}
function find_files($dir,$is_ext_dir=false,$ignore=false)
function find_files($dir,$is_ext_dir=FALSE,$ignore=FALSE)
{
global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested;
$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'))) {
$skip_ext = ($is_ext_dir && !in_array($name, $exts_to_test));
if ($skip_ext) {
$exts_skipped++;
}
find_files("{$dir}/{$name}", false, $ignore || $skip_ext);
find_files("{$dir}/{$name}", FALSE, $ignore || $skip_ext);
}
// Cleanup any left-over tmp files from last run.
@ -192,7 +192,6 @@ echo "TIME START " . date('Y-m-d H:i:s', $start_time) . "
$path_current = '';
foreach ($test_files as $name) {
$path = dirname($name);
if ($path_current != $path) {
$path_current = $path;
@ -292,7 +291,6 @@ TEST $file
";
// Load the sections of the test file.
$section_text = array(
'TEST' => '(unnamed test)',
'SKIPIF' => '',
@ -300,8 +298,7 @@ TEST $file
'ARGS' => '',
);
$fp = @fopen($file, "r")
or error("Cannot open test file: $file");
$fp = @fopen($file, "r") or error("Cannot open test file: $file");
$section = '';
while (!feof($fp)) {
@ -322,9 +319,9 @@ TEST $file
$tested = trim($section_text['TEST']).' ('.basename($file).')';
$tmp = realpath(dirname($file));
$tmp_skipif = $tmp.uniqid('/phpt.');
$tmp_file = $tmp.uniqid('/phpt.');
$tmp_post = $tmp.uniqid('/phpt.');
$tmp_skipif = $tmp . uniqid('/phpt.');
$tmp_file = $tmp . uniqid('/phpt.');
$tmp_post = $tmp . uniqid('/phpt.');
@unlink($tmp_skipif);
@unlink($tmp_file);
@ -352,7 +349,7 @@ TEST $file
save_text($tmp_skipif, $section_text['SKIPIF']);
$output = `$php $tmp_skipif`;
@unlink($tmp_skipif);
if(trim($output)=='skip') {
if (trim($output) == 'skip') {
echo "SKIP $tested\n";
return 'SKIPPED';
}
@ -362,17 +359,20 @@ TEST $file
// Any special ini settings
$ini_settings = '';
if (array_key_exists('INI', $section_text)) {
foreach(preg_split( "/[\n\r]+/", $section_text['INI']) as $setting)
if (strlen($setting))
foreach(preg_split( "/[\n\r]+/", $section_text['INI']) as $setting) {
if (strlen($setting)) {
$ini_settings .= " -d '$setting'";
}
}
}
// We've satisfied the preconditions - run the test!
save_text($tmp_file,$section_text['FILE']);
if (array_key_exists('GET', $section_text))
if (array_key_exists('GET', $section_text)) {
$query_string = trim($section_text['GET']);
else
} else {
$query_string = '';
}
putenv("REDIRECT_STATUS=1");
putenv("QUERY_STRING=$query_string");
@ -400,7 +400,6 @@ TEST $file
putenv("CONTENT_LENGTH=");
$cmd = "$php$ini_settings -f $tmp_file$args 2>&1";
}
if (DETAILED) echo "
@ -420,10 +419,10 @@ COMMAND $cmd
@unlink($tmp_file);
// Does the output match what is expected?
$output = trim($out);
$output = preg_replace('/\r\n/',"\n",$output);
if(isset($section_text['EXPECTF'])) {
if (isset($section_text['EXPECTF'])) {
$wanted = trim($section_text['EXPECTF']);
$wanted = preg_replace('/\r\n/',"\n",$wanted);
$wanted = preg_quote($wanted, '/');
@ -436,12 +435,12 @@ COMMAND $cmd
print(str_repeat('=', 80) . "\n");
var_dump($output);
*/
if(preg_match("/$wanted/s", $output)) {
if (preg_match("/$wanted/s", $output)) {
echo "PASS $tested\n";
return 'PASSED';
}
}
else {
} else {
$wanted = trim($section_text['EXPECT']);
$wanted = preg_replace('/\r\n/',"\n",$wanted);
// compare and leave on success
@ -456,10 +455,8 @@ COMMAND $cmd
echo "FAIL $tested\n";
// write .exp
if (strpos($log_format,'E')!==false) {
if (strpos($log_format,'E') !== FALSE) {
$logname = ereg_replace('\.phpt$','.exp',$file);
$log = fopen($logname,'w') or error("Cannot create test log - $logname");
fwrite($log,$wanted);
@ -467,7 +464,7 @@ COMMAND $cmd
}
// write .out
if (strpos($log_format,'O')!==false) {
if (strpos($log_format,'O') !== FALSE) {
$logname = ereg_replace('\.phpt$','.out',$file);
$log = fopen($logname,'w') or error("Cannot create test log - $logname");
fwrite($log,$output);
@ -475,7 +472,7 @@ COMMAND $cmd
}
// write .diff
if (strpos($log_format,'D')!==false) {
if (strpos($log_format,'D') !== FALSE) {
$logname = ereg_replace('\.phpt$','.diff',$file);
$log = fopen($logname,'w') or error("Cannot create test log - $logname");
fwrite($log,generate_diff($wanted,$output));
@ -483,7 +480,7 @@ COMMAND $cmd
}
// write .log
if (strpos($log_format,'L')!==false) {
if (strpos($log_format,'L') !== FALSE) {
$logname = ereg_replace('\.phpt$','.log',$file);
$log = fopen($logname,'w') or error("Cannot create test log - $logname");
fwrite($log,"
@ -525,7 +522,8 @@ function error($message)
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
* vim600: fdm=marker
* vim: noet sw=4 ts=4
*/
?>
Loading…
Cancel
Save