mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Add --EXPECTF-- section: 'sprintf' for EXPECT sections. See for usage
example ext/xslt/tests/009.phpt. # To aid debugging, a little commented section is left in, this can be # stripped in due time, or properly integrated with some --debugging flag. # But it's quite useful, when you make such tests.
This commit is contained in:
parent
2628482ee9
commit
bcddd58a92
@ -422,21 +422,42 @@ COMMAND $cmd
|
||||
// Does the output match what is expected?
|
||||
|
||||
$output = trim($out);
|
||||
$wanted = trim($section_text['EXPECT']);
|
||||
|
||||
$output = preg_replace('/\r\n/',"\n",$output);
|
||||
$wanted = preg_replace('/\r\n/',"\n",$wanted);
|
||||
|
||||
if(isset($section_text['EXPECTF'])) {
|
||||
$wanted = trim($section_text['EXPECTF']);
|
||||
$wanted = preg_replace('/\r\n/',"\n",$wanted);
|
||||
$wanted = preg_quote($wanted, '/');
|
||||
// Stick to basics
|
||||
$wanted = str_replace("%s", ".*?", $wanted); //not greedy
|
||||
$wanted = str_replace("%i", "[0-9]+", $wanted);
|
||||
$wanted = str_replace("%f", "[0-9\.+\-]+", $wanted);
|
||||
/* DEBUG YOUR REGEX HERE
|
||||
var_dump($wanted);
|
||||
print(str_repeat('=', 80) . "\n");
|
||||
var_dump($output);
|
||||
*/
|
||||
if(preg_match("/$wanted/s", $output)) {
|
||||
echo "PASS $tested\n";
|
||||
return 'PASSED';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$wanted = trim($section_text['EXPECT']);
|
||||
$wanted = preg_replace('/\r\n/',"\n",$wanted);
|
||||
// compare and leave on success
|
||||
$ok = (0 == strcmp($output,$wanted));
|
||||
if ($ok) {
|
||||
echo "PASS $tested\n";
|
||||
return 'PASSED';
|
||||
$ok = (0 == strcmp($output,$wanted));
|
||||
if ($ok) {
|
||||
echo "PASS $tested\n";
|
||||
return 'PASSED';
|
||||
}
|
||||
}
|
||||
|
||||
// Test failed so we need to report details.
|
||||
echo "FAIL $tested\n";
|
||||
|
||||
|
||||
|
||||
|
||||
// write .exp
|
||||
if (strpos($log_format,'E')!==false) {
|
||||
$logname = ereg_replace('\.phpt$','.exp',$file);
|
||||
|
Loading…
Reference in New Issue
Block a user