mirror of
https://github.com/php/php-src.git
synced 2024-10-05 16:56:11 +00:00
315f4f5658
Took the old PHP 3 regression testing framework and rewrote it in PHP. Should work on both Windows and UNIX, however I have not tested it on Windows. See tests/README for how to write tests. Added the PHP 3 tests and converted most of them.
86 lines
2.1 KiB
C++
Executable File
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/.
|
|
|
|
");
|
|
}
|
|
|
|
?>
|