run-tests.php
| From: | Zoe Slattery | Date: | Fri, 07 Sep 2007 08:38:11 +0000 |
| Subject: | run-tests.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-44811@lists.php.net to get a copy of this message | ||
Hi there
I just fell into a small trap with php-runtests.php. This test case shows it:
--TEST--
Testing regex matching in run-tests.phpt
--FILE--
<?php
echo "Warning: something wrong in function red at line 10\n";
echo "Warning: something wrong in function green at line 13\n";
echo "Write whatever you like, it will be swallowed at line 16\n";
?>
--EXPECTF--
Warning: something wrong in function %s at line %d
Warning: something wrong in function %s at line %d
This is a silly test but it passes. To make it fail properly it's necessary to put the line numbers in the expected output and not use with %d. We've used %d this way in quite a few tests :-( and I tripped over it an an error case test that has lots of similar lines of output.
%s is substituted by .+? in php-runtests.php and I think the regex matching (preg_match) is working correctly. I've found one file system test which is passing (and shouldn't be) because of this - I'll fix it later today.
If I'm correct in thinking that php-runtest.php is working as designed I think it might be a good idea to put something on the QA web pages (I'm happy to write it) to suggest that recommeded practice is to use exact line numbers in the expected output instead of %d. Now that I'm writing this it seems almost too obvious to state - but it didn't seem so obvious earlier in the year.
Comments?
Zoe Slattery
IBM