Etienne Kneuss

home » repository » php » php.net » docweb » analyzeTestResults.php
Tree:
school
mp3
php
sample
publications
Math_Derivative
Math_Expression
ircbot
php.net
docweb
phpt_entities.patch
phpt_generator.php
lib_phpt_generator.inc.php
phpt_edit.tpl.php
phpt_list.tpl.php
phpt_generator.patch
phpt_results.txt
analyzeTestResults.php
lsb
check-acronyms.php
spam_tickets.sql.txt
spam-protection.php
genphpt.php
fix-whitespace.php
generrorlinks.php
remove-ordie.php
docbkphp.vim
script-skel.php
cvslogger.php
generateCvslogs.php
images
dump

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.

Add a comment

Username:

Spam Challenge: 1+6=?

Comment: