Re: Re: PHPT and --FILEEOF--

From: Date: Thu, 30 Apr 2009 21:53:12 +0000
Subject: Re: Re: PHPT and --FILEEOF--
References: 1 2 3 4  Groups: php.qa 
Request: Send a blank email to php-qa+get-64842@lists.php.net to get a copy of this message
Eric Stewart wrote: > On Thu, Apr 30, 2009 at 1:08 PM, Nuno Lopes <nlopess@php.net > <mailto:nlopess@php.net>> wrote: > > When in doubt, refer to the source of run-tests.php and its commit > history. The big hint here is that FILEEOF replaces \r and \n > with '' > > helly added it to test for bug #35382 (which I found by > searching the > commit log at cvs.php.net <http://cvs.php.net> > first for > FILEEOF and then for 35382): > > [äa5owWgÆ¿ EüSØ > http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.237&r2=1.238 > > <http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.237&r2=1.238> > > It looks like at the time, the test would pass when it should > fail if > the comment line ended with \n or with \r or with \r\n. The > same is > true of the comments2.phpt test - the problem being tested for > is the > lexer failing when there is nothing after the closing bracket }. > > > I confirm this historical fact. So this section is really needed > and it's used in a few places already. > Nuno > > > Thanks everyone for looking into this. I didn't mean to imply that we > should remove the section. I was having trouble nailing down a proper > use case for it. I had found the two tests, but neither test alone > seem to validate it's use. I should have reviewed the bug report > though and that was my mistake. I think I'll document it's use based > on the two tests we do have for it, but include comments that it's a > rarely used edge-case specific feature. In other words, 99.99% of the > time, you wouldn't use this feature. Hi, I'd have to agree - in fact, it might be better to refactor this oddness so that special test setup such as pre-processing the file's contents or things like temporary file/directory creation could happen in a separate process. The easiest way to do this robustly would be to simply have a script that is passed the name of the testfile in a variable run in a separate process (much like --CLEAN--): --SETUP-- <?php $contents = file_get_contents($testfile); $contents = trim($contents); file_put_contents($testfile, $contents); ?> --FILE-- This way, any future manipulations needed can be done quite easily without adding new --FILE*-- This would work really nicely for --FILE_EXTERNAL-- as well (and I'm willing to refactor all of the phar tests that use FILE_EXTERNAL) There's a reason phpunit has setup/teardown methods outside the tests themselves - phpt could benefit from this model. Greg

« previous php.qa (#64842) next »