Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.0

Request #15928 Add 'skip all tests except' option to phpdt
Submitted: 2009-02-23 01:17 UTC
From: sofia Assigned: izi
Status: Closed Package: Testing_DocTest
PHP Version: 5.2.5 OS: mac
Roadmaps: (Not assigned)    
Subscription  


 [2009-02-23 01:17 UTC] sofia (sofia cardita)
Description: ------------ Say I have a class that has several doctests in it and I'm currently only working on one of the class methods. I would like a way to run only the test specified instead of all the tests in the class. That way I don't have to wait for all the tests to run to see the output of the method I'm currently testing. I've implemented a way to do this which is in the test script section. It would be used like this: phpdt -s "doctest name" file.php I was unsure about the name, it could also be runonly but since there was already a skip if flag it seemed more in tune with the project but feel free to change as you see fit. Test script: --------------- FILE: phpdt (around line 75) $parser->addOption('skipallexcept', array( 'short_name' => '-s', 'long_name' => '--skipallexcept', 'description' => 'Skip all tests except ?.', 'action' => 'StoreString' )); FILE: doctest/parser/default.php->parse() (around line 235) //skip all tests except option $reg = Testing_DocTest_Registry::singleton(); if ($reg->skipallexcept && $reg->skipallexcept != trim($this->_testCase->altname)) { $this->_testCase->flags |= constant('Testing_DocTest::FLAG_SKIP'); } // end skip all tests except option (after the 'trim last eol' and before the 'reset state' code) Expected result: ---------------- Actual result: --------------

Comments

 [2009-02-23 01:29 UTC] sofia (sofia cardita)
Just noticed that the line $reg = Testing_DocTest_Registry::singleton(); in the method parse of doctest/parser/default.php should not be inside the foreach loops but just before them, around line 177 so that we have [..] $reg = Testing_DocTest_Registry::singleton(); foreach ($files as $file) { [..] and later we have [..] //skip all tests except option if ($reg->skipallexcept && $reg->skipallexcept != trim($this->_testCase- >altname)) { $this->_testCase->flags |= constant('Testing_DocTest::FLAG_SKIP'); } [..]
 [2009-02-24 15:29 UTC] izi (David Jean Louis)
Hi Sofia, I like the idea, but I think it would be better to have something like: $ phpdt -t "test1" "test2" "another test" SomeFile.php $ phpdt --tests "test1" "test2" "another test" SomeFile.php This would make doctest runner run only the tests with names "test1" "test2" "another test" in the file "SomeFile.php". I think it's more flexible, what do you think ? -- David
 [2009-02-26 03:54 UTC] sofia (sofia cardita)
Hi David, Yup, that's better - more flexible and logical as well :) Sofia
 [2009-02-27 13:09 UTC] izi (David Jean Louis)
-Status: Open +Status: Closed -Assigned To: +Assigned To: izi
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Hi Sofia, implemented in CVS version, thanks !