Skip to content

Commit

Permalink
Don't show matching regex as different
Browse files Browse the repository at this point in the history
  • Loading branch information
helly25 committed Aug 9, 2003
1 parent e491d75 commit fe37ce8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ function run_test($php, $file)
} else {
$wanted = trim($section_text['EXPECT']);
$wanted = preg_replace('/\r\n/',"\n",$wanted);
// compare and leave on success
// compare and leave on success
$ok = (0 == strcmp($output,$wanted));
if ($ok) {
@unlink($tmp_file);
Expand All @@ -861,6 +861,7 @@ function run_test($php, $file)
}
return 'PASSED';
}
$wanted_re = NULL;
}

// Test failed so we need to report details.
Expand Down Expand Up @@ -898,7 +899,7 @@ function run_test($php, $file)
if (strpos($log_format,'D') !== FALSE) {
$logname = ereg_replace('\.phpt$','.diff',$file);
$log = fopen($logname,'w') or error("Cannot create test log - $logname");
fwrite($log,generate_diff($wanted,$output));
fwrite($log,generate_diff($wanted,$wanted_re,$output));
fclose($log);
}

Expand All @@ -924,10 +925,18 @@ function run_test($php, $file)
return $warn ? 'WARNED' : 'FAILED';
}

function generate_diff($wanted,$output)
function generate_diff($wanted,$wanted_re,$output)
{
$w = explode("\n", $wanted);
$o = explode("\n", $output);
if (!is_null($wanted_re)) {
$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];
}
}
}
$w1 = array_diff_assoc($w,$o);
$o1 = array_diff_assoc($o,$w);
$w2 = array();
Expand Down

0 comments on commit fe37ce8

Please sign in to comment.