The following patch produces *.diff files similar to
diff command. These would allow for easier checks in faild tests
when test combines multiple function checks in one test file
or the test uses var_dump for output.

For example i changed precision to 13 in array test 003.phpt
The tests now produce 003.diff
004-   float(-0.33333333333333)
004+   float(-0.3333333333333)
034-   float(-0.33333333333333)
034+   float(-0.3333333333333)
050-   float(-0.33333333333333)
050+   float(-0.3333333333333)

When the test fails because of memory leaks and such then
of cause .log files are better to read.

Any pros/cons?

Here is the diff

cvs -z3 -q diff -w run-tests.php (in directory S:\php4\)
Index: run-tests.php
===================================================================
RCS file: /repository/php4/run-tests.php,v
retrieving revision 1.53
diff -u -w -r1.53 run-tests.php
--- run-tests.php       21 Aug 2002 23:06:38 -0000      1.53
+++ run-tests.php       22 Aug 2002 00:34:57 -0000
@@ -420,9 +420,30 @@
  ");
      fclose($log);

+    $diffname = ereg_replace('\.phpt$','.diff',$file);
+    $diff = fopen($diffname,'w')
+        or error("Cannot create test log - $logname");
+
+    fwrite($diff,generate_diff($wanted,$output));
+    fclose($diff);
+
      error_report($file,$logname,$tested);

      return 'FAILED';
+}
+
+function generate_diff($wanted,$output) {
+    $w = explode("\n", $wanted);
+    $o = explode("\n", $output);
+    $w1 = array_diff($w,$o);
+    $o1 = array_diff($o,$w);
+    $w2 = array();
+    $o2 = array();
+    foreach($w1 as $idx => $val) $w2[sprintf("%03d<",$idx)] = 
sprintf("%03d- $val", $idx+1);
+    foreach($o1 as $idx => $val) $o2[sprintf("%03d>",$idx)] = 
sprintf("%03d+ $val", $idx+1);
+    $diff = array_merge($w2, $o2);
+    ksort($diff);
+    return implode("\r\n", $diff);
  }

  function error($message) {




------------------->>> mailto:[EMAIL PROTECTED] <<<------------------
"Wir sind allzumal Tiere unter Tieren, Kinder der Materie wie sie,
nur wehrloser. Doch da wir im Unterschied zu den Tieren wissen,
dass wir sterben muessen, wollen wir uns auf jenen Augenblick vorbereiten,
indem wir das Leben geniessen, das uns durch Zufall und vom Zufall gegeben 
ist."
                                 Umberto Eco, Die Insel des vorigen Tages
--------------------->>> http://marcus-boerger.de <<<---------------------
------------>>> Tel. 0241 / 874 09-7 ### 0179 / 29 14 980  <<<------------

Reply via email to