summaryrefslogtreecommitdiff
path: root/pear/run-tests.in
blob: d147f0a8061c95d3d86ec0c55148f09b9115faaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!@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/.

");
}

?>