Skip to content
Browse files

committing stable code on the way tio redir impl

  • Loading branch information...
1 parent d212f75 commit ca7438d6799e51f60e8c56ec93c5a39562f11f71 zoe slattery committed
View
1 src/run-tests.php
@@ -3,6 +3,7 @@
* Main php file for run-tests.php
*/
+
error_reporting(E_ALL);
/**
View
1 src/taskScheduler/rtTaskScheduler.php
@@ -131,6 +131,7 @@ public function run()
$task = $this->taskList[$i];
$task->run();
$results = $task->getResult();
+
rtTestOutputWriter::flushResult($results, $this->reportStatus);
$this->resultList[] = $results;
}
View
3 src/taskScheduler/rtTaskSchedulerFile.php
@@ -220,7 +220,8 @@ protected function child($cid)
print "ERROR unserialize - cid $cid\n";
continue;
}
-
+
+
$task->run();
$e = microtime(true);
View
2 src/taskScheduler/rtTaskTestGroup.php
@@ -32,7 +32,7 @@ public function __construct($runConfiguration, $subDirectory)
public function run()
{
$testGroup = new rtPhpTestGroup($this->runConfiguration, $this->subDirectory);
- $testGroup->runGroup($this->runConfiguration);
+ $testGroup->run();
$this->result = $testGroup->getResults();
return true;
}
View
2 src/testcase/rtPhpTest.php
@@ -106,7 +106,7 @@ public function executeTest(rtRuntestsConfiguration $runConfiguration)
$this->testStatus = $this->sections['SKIPIF']->run($this, $runConfiguration);
$this->testStatus->setExecutedPhpCommand($this->sections['SKIPIF']->getPhpCommand());
}
-
+ //TODO: D'oh - what is this meant to be?
if (!$this->testStatus->getValue('skip') && !$this->testStatus->getValue('skip')) {
$this->testStatus = $this->fileSection->run($this, $runConfiguration);
$this->testStatus->setExecutedPhpCommand($this->fileSection->getPhpCommand());
View
30 src/testgroup/rtGroupConfiguration.php
@@ -1 +1,31 @@
<?php
+/**
+ * rtGroupConfiguration
+ *
+ * Defines environment for a group of test. Could be either setting group
+ * environment variables (as in redirected tests) of setting parameters
+ * to stop the group being run in parallel
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <zoe@php.net>
+ * @author Stefan Priebsch <spriebsch@php.net>
+ * @copyright 2009 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License 3.01
+ *
+ */
+class rtGroupConfiguration
+{
+ protected $testDirectory;
+
+
+ public function __construct(rtRuntestsConfiguration $runConfiguration, $directory)
+ {
+ $this->testDirectory = $directory;
+ }
+
+ public function parseRedirect(rtPHPTest $redirectedTest) {
+ var_dump($redirectedTest->getSection('REDIRECTTEST'));
+ }
+}
+
View
41 src/testgroup/rtPhpTestGroup.php
@@ -12,19 +12,21 @@
* @license http://www.php.net/license/3_01.txt PHP License 3.01
*
*/
-class rtPhpTestGroup
+class rtPhpTestGroup extends rtTask implements rtTaskInterface
{
protected $testDirectory;
protected $testCases;
- protected $results;
+ protected $result = null;
+ protected $runConfiguration;
public function __construct(rtRuntestsConfiguration $runConfiguration, $directory)
{
+ $this->runConfiguration = $runConfiguration;
$this->testDirectory = $directory;
- $this->init($runConfiguration);
+ $this->init();
}
- public function init(rtRuntestsConfiguration $runConfiguration)
+ public function init()
{
$this->testFiles = rtUtil::getTestList($this->testDirectory);
@@ -47,13 +49,13 @@ public function init(rtRuntestsConfiguration $runConfiguration)
$testStatus = new rtTestStatus($testFile->getTestName());
if ($testFile->arePreconditionsMet() ) {
// Create a new test case
- $this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration, $testStatus);
+ $this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
} elseif (in_array("REDIRECTTEST",$testFile->getSectionHeadings())){
//Redirect handler, save the test case for processing after the main groups have finished.
//Check to make sure that it shouldn't be skipped, if skipped don't save it
- $redirectedTest= new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration, $testStatus);
+ $redirectedTest= new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
if($redirectedTest->hasSection('SKIPIF')) {
- $redirectedTest->runSkipif($runConfiguration);
+ $redirectedTest->runSkipif($this->runConfiguration);
if($redirectedTest->getStatus()->getValue('skip')) {
$testStatus->setTrue('skip');
$testStatus->setMessage('skip', $testFile->getExitMessage());
@@ -61,47 +63,48 @@ public function init(rtRuntestsConfiguration $runConfiguration)
$testStatus->setTrue('redirected');
$testStatus->setMessage('redirected', $testFile->getExitMessage());
}
- $this->results[] = new rtTestResults($redirectedTest, $testStatus);
+ $this->result[] = new rtTestResults($redirectedTest, $testStatus);
}
}else {
$testStatus->setTrue('bork');
$testStatus->setMessage('bork', $testFile->getExitMessage());
- $this->results[] = new rtTestResults(null, $testStatus);
+ $this->result[] = new rtTestResults(null, $testStatus);
}
}
}
- public function runGroup(rtRuntestsConfiguration $runConfiguration)
+ public function run()
{
+
if (count($this->testCases) == 0) {
return;
}
+
foreach ($this->testCases as $testCase) {
- $testCase->executeTest($runConfiguration);
+ $testCase->executeTest($this->runConfiguration);
$testResult = new rtTestResults($testCase);
- $testResult->processResults($testCase, $runConfiguration);
- $this->results[] = $testResult;
+ $testResult->processResults($testCase, $this->runConfiguration);
+ $this->result[] = $testResult;
}
}
public function writeGroup($outType, $cid=null)
{
- $testOutputWriter = rtTestOutputWriter::getInstance($this->results, $outType);
+ $testOutputWriter = rtTestOutputWriter::getInstance($this->result, $outType);
$testOutputWriter->write($this->testDirectory, $cid);
}
- public function getResults()
- {
- return $this->results;
- }
-
public function getTestCases() {
return $this->testCases;
}
+
+ public function getResults() {
+ return $this->result;
+ }
}
?>
View
20 src/testrun/rtPhpTestRun.php
@@ -56,12 +56,16 @@ public function run()
$php = $this->runConfiguration->getSetting('PhpExecutable');
$this->runConfiguration->setEnvironmentVariable('TEST_PHP_EXECUTABLE', $php);
-
+ // Main decision point. Either we start this with a directory (or set of directories, in which case tests are
+ // run as a group (and in parallel if required) or......
+ //
if ($this->runConfiguration->getSetting('TestDirectories') != null) {
$this->run_group($this->runConfiguration->getSetting('TestDirectories'));
} else {
+ //.. the input is a test file, or list of files and are just run as single tests
+ // and not in parallel
if ($this->runConfiguration->getSetting('TestFiles') == null) {
echo rtText::get('invalidTestFileName');
@@ -74,11 +78,13 @@ public function run()
if(count($this->redirectedTestCases) > 0) {
foreach($this->redirectedTestCases as $testCase){
echo $testCase->getName() . "\n";
+
+
}
+
//For each test case - construct a new group
//Call run_group() again with an array of groups
//
- // Need to run the skipif section first (Could this be done earlier?)
// The redirect section has PHP code in it but no tags.
// It is code the needs to be run as part of run-tests, not as a 'runnable' section -
// eek it's eval(). Is there any better way to do this? It's setting a 'group
@@ -123,9 +129,12 @@ public function run_group($testDirectories) {
// create the task-list
$taskList = array();
+
+
foreach ($subDirectories as $subDirectory) {
$taskList[] = new rtTaskTestGroup($this->runConfiguration, $subDirectory);
}
+
// run the task-scheduler
$scheduler = rtTaskScheduler::getInstance();
@@ -146,6 +155,7 @@ public function run_group($testDirectories) {
}
}
}
+
// create output
$type = null;
@@ -183,10 +193,7 @@ public function run_tests($testNames) {
$testFile = new rtPhpTestFile();
$testFile->doRead($testName);
$testFile->normaliseLineEndings();
-
- // var_dump($testFile->getSectionHeadings());
- // var_dump($testFile->getContents());
-
+
$testStatus = new rtTestStatus($testFile->getTestName());
@@ -204,6 +211,7 @@ public function run_tests($testNames) {
//Redirect handler
//Build a list of redirected test cases
+ //TODO: need to run the skipif section here..
$this->redirectedTestCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
$testStatus->setTrue('redirected');
View
7 tests/rtPhpTestGroupTest.php
@@ -16,11 +16,11 @@ public function testCreateInstance()
$config->configure();
$phpTestGroup = new rtPhpTestGroup($config, $directory);
-
+
$validTestCaseCount = count($phpTestGroup->getTestCases());
$phptFileCount = count(glob($directory . "/*.phpt"));
- $inValidTestCaseCount = count($phpTestGroup->getResults());
+ $inValidTestCaseCount = count($phpTestGroup->getResult());
//PhpTestGroup should divide the test cases into valid tests (TestCases),
//or invalid ones. An invalid test is either one which 'borks' (that is, the
@@ -39,10 +39,11 @@ public function testFindRedirect()
$config->configure();
$phpTestGroup = new rtPhpTestGroup($config, $directory);
+
- $inValidTests = $phpTestGroup->getResults();
+ $inValidTests = $phpTestGroup->getResult();
foreach($inValidTests as $testResult) {
if($testResult->getStatus() == 'redirected') {

0 comments on commit ca7438d

Please sign in to comment.
Something went wrong with that request. Please try again.