EXPECT replacevars in test harness
| From: | Melvyn Sopacua | Date: | Sun, 06 Oct 2002 18:58:34 +0000 |
| Subject: | EXPECT replacevars in test harness | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-89097@lists.php.net to get a copy of this message | ||
Hi,
there was a memory leak in the xslt extension, which down the line, can be
re-introduced.
The problem is, that it cannot be tested for, since it requires an error to
be generated and output. The error contains the filename, which is random.
There are 2 things you can do:
1) str_replace the generated filename from the output, so that you can create
a test which depends on error output. Nice for this case, not very usefull
in other cases
2) Create a 'replacevars' in the expect section, which are either stripped or
replaced by a specific string. This would allow for more flexibility in
creating tests in general. For BC reasons this warrants a seperate section.
I was thinking of something like:
--EXPECT_SPRINTF--
Argument is not a valid array in %s, line %i.
This section should then be preprocessed as:
$expect_sprintf = preg_quote($expect_sprintf);
str_replace("%s", ".*?", $expect_sprintf);
str_replace("%i", "[0-9]+", $expect_sprintf);
And match as:
preg_match("/$expect_sprintf/s", $expect_sprintf);
Would this be worthwhile? I can put it in, if I have the Karma.
Met vriendelijke groeten / With kind regards,
Webmaster IDG.nl
Melvyn Sopacua