com phpruntests: Changes to deal with parsing tests that contain section key words inside teh section: src/testcase/rtPhpTest.php
src/testcase/rtPhpTestFile.php
| From: | David Soria Parra | Date: | Wed, 01 Jul 2009 20:16:12 +0000 |
| Subject: | com phpruntests: Changes to deal with parsing tests that contain section key words inside teh section: src/testcase/rtPhpTest.php src/testcase/rtPhpTestFile.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66382@lists.php.net to get a copy of this message | ||
Commit: e8f4c0052b5c5749caa4940904992f73f924a5aa
Author: Zoe Slattery <zoe@php.net> Wed, 1 Jul 2009 20:16:12 +0000
Parents: f71abf8d66d8250dde24c373dd682e1f84743836
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=e8f4c0052b5c5749caa4940904992f73f924a5aa
Log:
Changes to deal with parsing tests that contain section key words inside teh section
Changed paths:
M src/testcase/rtPhpTest.php
M src/testcase/rtPhpTestFile.php
Diff:
diff --git a/src/testcase/rtPhpTest.php b/src/testcase/rtPhpTest.php
index dc33ad5..36f8fc1 100644
--- a/src/testcase/rtPhpTest.php
+++ b/src/testcase/rtPhpTest.php
@@ -40,29 +40,40 @@ class rtPhpTest
*/
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]);
+
+ for ($sectionCount = 0; $sectionCount < count ($this->sectionHeadings) -1 ;
$sectionCount++) {
+
+ $sectionKey = $this->sectionHeadings[$sectionCount];
+ $nextSectionKey = $this->sectionHeadings[$sectionCount + 1];
+ $tempArray = array();
+
+ $contentPointer = 0;
+ for ($i=0; $i<count($this->contents); $i++) {
+ if($this->contents[$i] == $sectionKey) {
+ for ($j=$i+1; $j<count($this->contents); $j++) {
+ if ($this->contents[$j] == $nextSectionKey ||
stripos($this->contents[$j], "===done===") !== false) {
+ if(stripos($this->contents[$j], "===done===") !== false) {
+ $tempArray[] = trim($this->contents[$j]);
+ }
+
+ $testSection = rtSection::getInstance($sectionKey, $tempArray);
+ $this->sections[$sectionKey] = $testSection;
+ $contentPointer = $j;
+ break;
}
- $testSection = rtSection::getInstance($sectionKey, $tempArray);
- $this->sections[$sectionKey] = $testSection;
- break;
+ $tempArray[] = $this->contents[$j];
}
- $tempArray[] = $this->contents[$j];
}
}
}
- $testSection = rtSection::getInstance($sectionKey, $tempArray);
- $this->sections[$sectionKey] = $testSection;
+
+ $tempArray = array();
+ for ($k = $contentPointer +1; $k < count($this->contents); $k++) {
+ $tempArray[] = $this->contents[$k];
+ }
+ $testSection = rtSection::getInstance($nextSectionKey, $tempArray);
+ $this->sections[$nextSectionKey] = $testSection;
//Identify the file and expect section types
@@ -71,23 +82,23 @@ class rtPhpTest
$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 +130,7 @@ class rtPhpTest
/**
* Test the output against the expect section
- *
+ *
*/
public function compareOutput()
{
@@ -132,10 +143,10 @@ class rtPhpTest
}
}
-
+
/**
* Test the expected headers against actual headers. Only relevant for CGI tests.
- *
+ *
*/
public function compareHeaders()
{
@@ -148,10 +159,10 @@ class rtPhpTest
}
}
-
+
/**
* Identify a section heading
- *
+ *
*/
private function isSectionKey($line)
{
@@ -180,7 +191,7 @@ class rtPhpTest
}
}
-
+
/**
* Sets the test's expect section
*/
@@ -223,9 +234,9 @@ class rtPhpTest
{
return $this->sections[$sectionKey];
}
-
+
/*
- * Return the object containing all test status
+ * Return the object containing all test status
*/
public function getStatus()
{
diff --git a/src/testcase/rtPhpTestFile.php b/src/testcase/rtPhpTestFile.php
index 554f2f6..f5766f9 100644
--- a/src/testcase/rtPhpTestFile.php
+++ b/src/testcase/rtPhpTestFile.php
@@ -48,7 +48,7 @@ class rtPhpTestFile
for ($i=0; $i<count($this->testContents); $i++) {
//This is not nice but there are a huge number of tests with random spacs at the
end of the section header
//and empty sections.
- if (preg_match("/--([A-Z]+(_[A-Z]+|))--/", $this->testContents[$i],
$matches)) {
+ if (preg_match("/^\s*--([A-Z]+(_[A-Z]+|))--/",
$this->testContents[$i], $matches)) {
//look ahead to next section unless this is the last test section.
//if the EXPECT section is empty (missing) it will be caught by preconditions.
//If the next line is also a section heading than skip adding it to the test
case or headings.
@@ -63,6 +63,7 @@ class rtPhpTestFile
}
}
$this->testContents = $tempArray;
+
}
public function arePreConditionsMet()