From 06b089d63b1868d49a6beb395171b3465c8d470c Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 9 Aug 2003 17:21:19 +0000 Subject: Complain about borked tests instead of spitting out errors --- run-tests.php | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'run-tests.php') diff --git a/run-tests.php b/run-tests.php index 394601b73f..1071d6f7ff 100755 --- a/run-tests.php +++ b/run-tests.php @@ -247,7 +247,7 @@ Synopsis: Options: -l Read the testfiles to be executed from . After the test has finished all failed tests are written to the same . - If the list is empty and now further test is specified then + If the list is empty and no further test is specified then all tests are executed. -r Read the testfiles to be executed from . @@ -641,7 +641,7 @@ TEST $file // Load the sections of the test file. $section_text = array( - 'TEST' => '(unnamed test)', + 'TEST' => '', 'SKIPIF' => '', 'GET' => '', 'ARGS' => '', @@ -649,7 +649,17 @@ TEST $file $fp = @fopen($file, "r") or error("Cannot open test file: $file"); - $section = ''; + if (!feof($fp)) { + $line = fgets($fp); + } else { + echo "BORK empty test [$file]\n"; + return 'BORKED'; + } + if (!ereg('^--TEST--',$line,$r)) { + echo "BORK tests must start with --TEST-- [$file]\n"; + return 'BORKED'; + } + $section = 'TEST'; while (!feof($fp)) { $line = fgets($fp); @@ -663,6 +673,14 @@ TEST $file // Add to the section text. $section_text[$section] .= $line; } + if (!@count($section_text['FILE'])) { + echo "BORK missing section --FILE-- [$file]\n"; + return 'BORKED'; + } + if (!(@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX']))) { + echo "BORK missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX-- [$file]\n"; + return 'BORKED'; + } fclose($fp); /* For GET/POST tests, check if cgi sapi is avaliable and if it is, use it. */ @@ -868,7 +886,7 @@ COMMAND $cmd if ($warn) { echo "WARN $tested$info\n"; } else { - echo "FAIL $tested\n"; + echo "FAIL $tested$info\n"; } $PHP_FAILED_TESTS[] = array( @@ -933,7 +951,7 @@ function generate_diff($wanted,$wanted_re,$output) $r = explode("\n", $wanted_re); for($idx = 0; $idx < min(count($o),count($r)); $idx++) { if (preg_match('/^'.$r[$idx].'$/s', $o[$idx])) { - $w[$idx] = $o[$idx]; + $w[$idx] = $o[$idx]; } } } @@ -945,6 +963,8 @@ function generate_diff($wanted,$wanted_re,$output) foreach($o1 as $idx => $val) $o2[sprintf("%03d>",$idx)] = sprintf("%03d+ ", $idx+1).$val; $diff = array_merge($w2, $o2); ksort($diff); + $r = is_null($wanted_re) ? $w : explode("\n", $wanted_re); + $diff = generate_array_diff($r,$o,!is_null($wanted_re),$w); return implode("\r\n", $diff); } @@ -987,7 +1007,7 @@ function compute_summary() $n_total = count($test_results); $n_total += $ignored_by_ext; - $sum_results = array('PASSED'=>0, 'WARNED'=>0, 'SKIPPED'=>0, 'FAILED'=>0); + $sum_results = array('PASSED'=>0, 'WARNED'=>0, 'SKIPPED'=>0, 'FAILED'=>0, 'BORKED'=>0); foreach ($test_results as $v) { $sum_results[$v]++; } @@ -1014,7 +1034,12 @@ Exts tested : " . sprintf("%4d",$exts_tested) . " "; } $summary .= " -Number of tests : " . sprintf("%4d",$n_total) . " +Number of tests : " . sprintf("%4d",$n_total); + if ($sum_results['BORKED']) { + $summary .= " +Tests borked : " . sprintf("%4d (%2.1f%%)",$sum_results['BORKED'],$percent_results['BORKED']); + } + $summary .= " Tests skipped : " . sprintf("%4d (%2.1f%%)",$sum_results['SKIPPED'],$percent_results['SKIPPED']) . " Tests warned : " . sprintf("%4d (%2.1f%%)",$sum_results['WARNED'],$percent_results['WARNED']) . " Tests failed : " . sprintf("%4d (%2.1f%%)",$sum_results['FAILED'],$percent_results['FAILED']) . " -- cgit v1.2.1