php-src/pear/run-tests.in
Stig Bakken def1424b12 @Added XML_Parser class in PEAR (Stig)
@Added "make test" target in pear/ and added some regression tests (Stig)
Also fixed a bug in the PEAR class that was discovered when testing :-)
2000-07-30 17:41:31 +00:00

86 lines
2.1 KiB
C++
Executable File

#!@prefix@/bin/php -f
<?php // -*- C++ -*-
$prefix = "@prefix@";
$bindir = "@prefix@/bin";
$php = "$bindir/php";
$installdir = '@PEAR_INSTALLDIR@';
$extdir = '@EXTENSION_DIR@';
$abs_srcdir = '@abs_srcdir@/pear';
$incpath = ".:$abs_srcdir/pear/tests:$abs_srcdir/pear/tests";
$start = "*";
if ($argc > 1) {
$start = implode(" ", $argv);
}
$fp = popen("find $start -name tests -type d -print", "r");
if (!$fp) {
die("Could not run find!\n");
}
$failed = 0;
$passed = 0;
$tests = 0;
while ($dir = trim(fgets($fp, 1024))) {
print "DIRECTORY : $dir\n";
//print "dir=$dir\n";
$dp = opendir($dir);
while ($ent = readdir($dp)) {
if (substr($ent, 0, 1) == "." || substr($ent, -2) != ".t") {
continue;
}
$res = substr($ent, 0, -1) . 'r';
$out = substr($ent, 0, -1) . 'o';
$cmd = ("cd $dir; $php -d include_path=$incpath ".
"-d auto_prepend_file=none ".
"-d html_errors=no ".
"-f $ent 2>/dev/null | ".
"tee $out 2>/dev/null | cmp -s $res -");
//print "cmd=$cmd\n";
$err = 0;
system($cmd, &$err);
if ($err) {
print "FAILED : ";
$failed++;
} else {
unlink("$dir/$out");
print "PASSED : ";
$passed++;
}
$tests++;
print "$dir/$ent";
if ($err) {
print " (see $dir/$out)";
}
print "\n";
}
closedir($dp);
}
pclose($fp);
$percent = $failed ? ($passed * 100) / $tests : 100;
$percentstr = sprintf($percent < 10.0 ? "%.1f%%" : "%.0f%%", $percent);
print "\n----------- SUMMARY -----------\n";
printf("Tests performed: %d\n".
"Tests passed: %d\n".
"Tests failed: %d\n".
"Success rate: %s\n",
$tests, $passed, $failed, $percentstr);
if ($failed) {
die("
One or more tests failed. The file where you can find the output
from the test (.o file) should be listed after the FAILED message. The
expected output can be found in the corresponding .r file, the source code
for the test can be found in the .t file.
Please compare the actual output with the expected output and see if
it is a local configuration problem or an actual bug. If it is a bug,
please report it at http://bugs.php.net/.
");
}
?>