Source code raw phps
<?php
if (empty($_SERVER['argv'][1])) {
echo "usage: ".$_SERVER['argv'][0]." <tests dir>";
die(1);
}
$dir = rtrim($_SERVER['argv'][1], '/').'/';
$stats = array('total' => 0,
'ok' => 0,
'ext' => 0,
'failure' => 0,
'ws' => 0,
);
ob_start();
foreach(glob($dir.'*.phpt') as $name) {
$content = file_get_contents($name);
$n = preg_match('/--TEST--\n(.+)\n--FILE--/s', $content, $matches);
$matches[1] = preg_replace('/\s+/', ' ', $matches[1]);
$stats['total']++;
// Get the difference of exp/out
$name_noext = pathinfo($name, PATHINFO_FILENAME);
if (!file_exists($dir.$name_noext.'.exp')
|| !file_exists($dir.$name_noext.'.out')) {
$stats['ok']++;
// no errors, OK
continue;
}
// check for a missing ext type of error
$content_out = file_get_contents($dir.$name_noext.'.out');
if (strpos($content_out, 'Call to undefined') !== false) {
// missing Ext
$stats['ext']++;
continue;
}
$whitespace = false;
$content_exp = file_get_contents($dir.$name_noext.'.exp');
if (preg_replace('/\s+/', '', $content_exp) === preg_replace('/\s+/', '', $content_out)) {
$stats['ws']++;
$whitespace = true;
}
$stats['failure']++;
echo "\n\n".str_repeat('=', 80)."\n= File: $name\n= Title: $matches[1]\n".($whitespace?"**Most likely to be caused by whitespaces issue**\n":"").str_repeat('=', 80)."\n";
$diff = `diff -u $dir$name_noext.exp $dir$name_noext.out`;
$diff_lines = explode("\n", $diff);
foreach($diff_lines as $key => $line) {
if (empty($line) || $line[0] === '\\') {
unset($diff_lines[$key]);
}
}
if (!empty($diff_lines)) {
echo "> Difference detected in $name_noext : \n";
echo implode("\n", $diff_lines);
}
}
$output = ob_get_clean();
// results
echo "Results:\n";
echo " Total: $stats[total]\n";
echo " OK: $stats[ok] (".round(100*$stats['ok']/$stats['total'])."%)\n";
echo " Ext: $stats[ext] (".round(100*$stats['ext']/$stats['total'])."%)\n";
echo " Failures: $stats[failure] (".round(100*$stats['failure']/$stats['total'])."%), (".round(100*$stats['ws']/$stats['failure'])."% WS issues)\n";
echo "\nDiffs:\n";
echo $output;
?>
Comments
There is currently no comment here.