From bcddd58a926652b810a9f5f2abdd828fd6c57182 Mon Sep 17 00:00:00 2001 From: Melvyn Sopacua Date: Mon, 7 Oct 2002 00:05:20 +0000 Subject: [PATCH] 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. --- run-tests.php | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/run-tests.php b/run-tests.php index 9b2a34af30..f2f1e1a230 100755 --- a/run-tests.php +++ b/run-tests.php @@ -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); -- 2.40.0