zoe Sun Jul 5 17:22:16 2009 UTC Modified files: /phpruntests/src/testcase rtPhpTest.php rtPhpTestFile.php Log: rewritten parser - was failing on some sections http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/rtPhpTest.php?r1=1.13&r2=1.14&diff_format=u Index: phpruntests/src/testcase/rtPhpTest.php diff -u phpruntests/src/testcase/rtPhpTest.php:1.13 phpruntests/src/testcase/rtPhpTest.php:1.14 --- phpruntests/src/testcase/rtPhpTest.php:1.13 Thu Jul 2 10:22:59 2009 +++ phpruntests/src/testcase/rtPhpTest.php Sun Jul 5 17:22:15 2009 @@ -40,30 +40,44 @@ */ public function parse() { - for ($i=0; $i<count($this->contents); $i++) { - //Create an array of section objects - if ($this->isSectionKey($this->contents[$i])) { - $sectionKey = $this->contents[$i]; - - $tempArray = array(); - for ($j=$i+1; $j<count($this->contents); $j++) { - - if ($this->isSectionKey($this->contents[$j]) || stripos($this->contents[$j], "===done===") !== false) { - if(stripos($this->contents[$j], "===done===") !== false) { - $tempArray[] = trim($this->contents[$j]); + $lastSection = end($this->sectionHeadings); + + foreach($this->sectionHeadings as $keyNumber => $sectionKey) { + if($keyNumber < count($this->sectionHeadings) - 1) { + $nextKey = $this->sectionHeadings[$keyNumber + 1]; + } + $tempArray=array(); + foreach($this->contents as $lineNumber => $line) { + if($line == "--".$sectionKey."--") { + //Found the beginning of the section + + for($contentsLine=$lineNumber + 1; $contentsLine<count($this->contents); $contentsLine ++) { + + if( ($this->contents[$contentsLine] == "--".$nextKey."--") || ($contentsLine == count($this->contents))) { + //Found the end of the section OR the end of the test + $lineNumber --; + $sectionContents = array(); + foreach($tempArray as $line) { + //Check for a ===DONE== + $sectionContents[] = $line; + if(stripos($line, "===done===") !== false) { + break; + } + } + $testSection = rtSection::getInstance($sectionKey, $sectionContents); + $this->sections[$sectionKey] = $testSection; + break; + } else { + $tempArray[] = $this->contents[$contentsLine]; } - $testSection = rtSection::getInstance($sectionKey, $tempArray); - $this->sections[$sectionKey] = $testSection; - break; } - $tempArray[] = $this->contents[$j]; } } } + + $testSection = rtSection::getInstance($lastSection, $tempArray); + $this->sections[$lastSection] = $testSection; - $testSection = rtSection::getInstance($sectionKey, $tempArray); - $this->sections[$sectionKey] = $testSection; - //Identify the file and expect section types $this->fileSection = $this->setFileSection(); @@ -71,23 +85,23 @@ $this->fileSection->setExecutableFileName($this->getName()); } - + /** * Initialises the configuration for this test. Uses the configuration sections from teh test case - * + * * @param rtRunTEstsConfiuration $runConfiguration - * + * */ public function init(rtRuntestsConfiguration $runConfiguration) { $this->testConfiguration = new rtTestConfiguration($runConfiguration, $this->sections, $this->sectionHeadings, $this->fileSection); } - + /** * Executes the test case - * + * * @param rtRunTEstsConfiuration $runConfiguration */ public function executeTest(rtRuntestsConfiguration $runConfiguration) @@ -119,7 +133,7 @@ /** * Test the output against the expect section - * + * */ public function compareOutput() { @@ -132,10 +146,10 @@ } } - + /** * Test the expected headers against actual headers. Only relevant for CGI tests. - * + * */ public function compareHeaders() { @@ -148,10 +162,10 @@ } } - + /** * Identify a section heading - * + * */ private function isSectionKey($line) { @@ -180,7 +194,7 @@ } } - + /** * Sets the test's expect section */ @@ -223,9 +237,9 @@ { return $this->sections[$sectionKey]; } - + /* - * Return the object containing all test status + * Return the object containing all test status */ public function getStatus() { http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/rtPhpTestFile.php?r1=1.6&r2=1.7&diff_format=u Index: phpruntests/src/testcase/rtPhpTestFile.php diff -u phpruntests/src/testcase/rtPhpTestFile.php:1.6 phpruntests/src/testcase/rtPhpTestFile.php:1.7 --- phpruntests/src/testcase/rtPhpTestFile.php:1.6 Wed Jul 1 20:16:12 2009 +++ phpruntests/src/testcase/rtPhpTestFile.php Sun Jul 5 17:22:15 2009 @@ -55,7 +55,7 @@ if($i< count($this->testContents) - 1) { if (!preg_match("/--([A-Z]+(_[A-Z]+|))--/", $this->testContents[$i+1])) { $this->sectionHeadings[] = $matches[1]; - $tempArray[] = $matches[1]; + $tempArray[] = "--".$matches[1]."--"; } } } else {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php