mirror of
https://github.com/php/phpruntests.git
synced 2026-03-23 23:52:11 +01:00
Adding and testing code to read skipif.inc files to enable whole directory skips
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
</target>
|
||||
|
||||
<target name="lint" description="Lint check all PHP files.">
|
||||
<phplint haltonfailure="true">
|
||||
<phplint haltonfailure="true" level="debug">
|
||||
<fileset dir="src">
|
||||
<include name="*.php"/>
|
||||
<include name="**/*.php"/>
|
||||
|
||||
8
phpt-tests/group_of_tests/sample_test.phpt
Normal file
8
phpt-tests/group_of_tests/sample_test.phpt
Normal file
@@ -0,0 +1,8 @@
|
||||
--TEST--
|
||||
Try a sample test
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Hello world\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello world
|
||||
3
phpt-tests/group_of_tests/skipif.inc
Normal file
3
phpt-tests/group_of_tests/skipif.inc
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
echo "skip me please \n";
|
||||
?>
|
||||
@@ -20,8 +20,6 @@ function rtExceptionHandler(Exception $e) {
|
||||
set_exception_handler('rtExceptionHandler');
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* check the version of the running php-executable and
|
||||
* ensure that is 5.3 or higher
|
||||
|
||||
@@ -98,7 +98,7 @@ abstract class rtTestOutputWriter
|
||||
* @param integer $processCount
|
||||
* @return string
|
||||
*/
|
||||
public function getOverview($parallelGroups = 0, $serialGroups= 0, $processCount)
|
||||
public function getOverview($parallelGroups = 0, $serialGroups= 0, $processCount, $skippedGroups)
|
||||
{
|
||||
// if the overview was already created retun it
|
||||
if (!is_null($this->overview)) {
|
||||
@@ -134,6 +134,12 @@ abstract class rtTestOutputWriter
|
||||
$str = '';
|
||||
|
||||
$str .= "\n\n----------------------------------------\n";
|
||||
$str .= "Number of skipped groups:";
|
||||
$blanks = 30 - strlen("Number of skipped groups:") - strlen(count($skippedGroups));
|
||||
$str = $this->writeBlanks($str, $blanks);
|
||||
$str .= count($skippedGroups);
|
||||
$str .= "\n----------------------------------------\n";
|
||||
|
||||
$str .= "Tests:";
|
||||
$blanks = 30 - strlen("Tests:") - strlen($count);
|
||||
$str = $this->writeBlanks($str, $blanks);
|
||||
@@ -194,9 +200,9 @@ abstract class rtTestOutputWriter
|
||||
}
|
||||
|
||||
|
||||
public function printOverview($parallelGroups=NULL, $serialGroups = NULL, $processCount=NULL) {
|
||||
public function printOverview($parallelGroups=NULL, $serialGroups = NULL, $processCount=NULL, $skippedGroups=null) {
|
||||
|
||||
print $this->getOverview($parallelGroups, $serialGroups, $processCount);
|
||||
print $this->getOverview($parallelGroups, $serialGroups, $processCount, $skippedGroups);
|
||||
flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ class rtGroupConfiguration
|
||||
protected $isRedirect=false;
|
||||
protected $serialGroup=false;
|
||||
protected $redirectFromID = null;
|
||||
protected $skipFile = "";
|
||||
protected $hasSkipCode = false;
|
||||
|
||||
|
||||
public function __construct($directory)
|
||||
@@ -29,8 +31,7 @@ class rtGroupConfiguration
|
||||
}
|
||||
|
||||
public function parseRedirect(rtPHPTest $redirectedTest) {
|
||||
//Going to assume that we have already parsed the SKIPIF (if it exists)
|
||||
//var_dump($redirectedTest->getSection('REDIRECTTEST')->getContents());
|
||||
|
||||
$name = $redirectedTest->getName();
|
||||
|
||||
$code = implode($redirectedTest->getSection('REDIRECTTEST')->getContents(), "\n");
|
||||
@@ -75,7 +76,7 @@ class rtGroupConfiguration
|
||||
//Find the key in the full name of the test contains the redirect
|
||||
$position = strpos($name, $key);
|
||||
|
||||
//Take the root strng from before the key
|
||||
//Take the root string from before the key
|
||||
$root=substr($name, 0, $position);
|
||||
|
||||
$title = $redirectedTest->getSection('TEST')->getContents();
|
||||
@@ -94,14 +95,22 @@ class rtGroupConfiguration
|
||||
|
||||
}
|
||||
|
||||
public function parse() {
|
||||
//Here insert code to read a config file from the test directory that determines whether the set of tests shoudl be run
|
||||
public function parseConfiguration() {
|
||||
//Here insert code to read a config file from the test directory that determines whether the set of tests should be run
|
||||
//in parallel or not?
|
||||
$this->serialGroup = false;
|
||||
|
||||
|
||||
//Code to read the directory skipif, run it and skip the directory
|
||||
if(file_exists($this->testDirectory. "/skipif.inc")) {
|
||||
$this->hasSkipCode = true;
|
||||
$this->skipFile = $this->testDirectory."/skipif.inc";
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getEnvironmentVariables() {
|
||||
return $this->environmentVariables;
|
||||
}
|
||||
@@ -116,6 +125,12 @@ class rtGroupConfiguration
|
||||
}
|
||||
public function getRedirectFromID() {
|
||||
return $this->redirectFromID;
|
||||
}
|
||||
}
|
||||
public function hasSkipCode() {
|
||||
return $this->hasSkipCode;
|
||||
}
|
||||
public function getSkipFile() {
|
||||
return $this->skipFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class rtGroupResults
|
||||
protected $runOrder;
|
||||
protected $runByProcessor = 0;
|
||||
protected $absTime;
|
||||
protected $isSkipGroup = false;
|
||||
|
||||
public function __construct($gn) {
|
||||
$this->groupName = $gn;
|
||||
@@ -68,6 +69,10 @@ class rtGroupResults
|
||||
public function setProc($p) {
|
||||
$this->runByProcessor = $p;
|
||||
}
|
||||
public function setSkip($s) {
|
||||
$this->isSkipGroup = $s;
|
||||
}
|
||||
|
||||
public function getTime() {
|
||||
return $this->timeToRun;
|
||||
}
|
||||
@@ -82,6 +87,9 @@ class rtGroupResults
|
||||
public function getAbsTime() {
|
||||
return $this->absTime;
|
||||
}
|
||||
public function isSkipGroup() {
|
||||
return $this->isSkipGroup;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -19,112 +19,136 @@ class rtPhpTestGroup extends rtTask implements rtTaskInterface
|
||||
protected $runConfiguration;
|
||||
protected $groupConfiguration;
|
||||
protected $groupResults;
|
||||
|
||||
|
||||
|
||||
public function __construct(rtRuntestsConfiguration $runConfiguration, $directory, $groupConfiguration)
|
||||
{
|
||||
$this->runConfiguration = $runConfiguration;
|
||||
$this->runConfiguration = $runConfiguration;
|
||||
$this->testDirectory = $directory;
|
||||
$this->groupConfiguration = $groupConfiguration;
|
||||
$this->groupConfiguration = $groupConfiguration;
|
||||
$this->groupResults = new rtGroupResults($directory);
|
||||
$this->init();
|
||||
}
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
unset ($this->testCases);
|
||||
unset ($this->groupResults);
|
||||
|
||||
unset ($this->testCases);
|
||||
unset ($this->groupResults);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
if($this->groupConfiguration->isRedirect()) {
|
||||
//merge in environmental variables (this is for REDEIRRECT).
|
||||
foreach($this->groupConfiguration->getEnvironmentVariables() as $key=>$value) {
|
||||
$this->runConfiguration->setEnvironmentVariable($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->testFiles = rtUtil::getTestList($this->testDirectory);
|
||||
|
||||
$redirectFromID = $this->groupConfiguration->getRedirectFromID();
|
||||
|
||||
foreach ($this->testFiles as $testFileName) {
|
||||
//echo "\n" .memory_get_usage() . ", setup start". $testFileName . "\n";
|
||||
|
||||
//testFiles is a list of file names relative to the current working directory
|
||||
|
||||
if (!file_exists($testFileName)) {
|
||||
echo rtText::get('invalidTestFileName', array($testFileName));
|
||||
exit();
|
||||
{
|
||||
if($this->groupConfiguration->isRedirect()) {
|
||||
//merge in environmental variables (this is for REDEIRRECT).
|
||||
foreach($this->groupConfiguration->getEnvironmentVariables() as $key=>$value) {
|
||||
$this->runConfiguration->setEnvironmentVariable($key, $value);
|
||||
}
|
||||
|
||||
// Create a new test file object;
|
||||
$testFile = new rtPhpTestFile();
|
||||
$testFile->doRead($testFileName);
|
||||
$testFile->normaliseLineEndings();
|
||||
|
||||
//The test name is the full path to the test file name without the .phpt
|
||||
|
||||
$testStatus = new rtTestStatus($testFile->getTestName());
|
||||
if ($testFile->arePreconditionsMet() ) {
|
||||
// Create a new test case
|
||||
$this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus, $redirectFromID);
|
||||
} 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(), $this->runConfiguration, $testStatus);
|
||||
if($redirectedTest->hasSection('SKIPIF')) {
|
||||
$redirectedTest->runSkipif($this->runConfiguration);
|
||||
if($redirectedTest->getStatus()->getValue('skip')) {
|
||||
$testStatus->setTrue('skip');
|
||||
$testStatus->setMessage('skip', $testFile->getExitMessage(). ' and the skip condition has failed');
|
||||
$this->groupResults->setTestStatus($testFile->getTestName(), $testStatus);
|
||||
} else {
|
||||
$testStatus->setTrue('redirected');
|
||||
$testStatus->setMessage('redirected', $testFile->getExitMessage());
|
||||
$this->groupResults->setTestStatus($testFile->getTestName(), $testStatus);
|
||||
$this->groupResults->setRedirectedTestCase($redirectedTest);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($this->groupConfiguration->hasSkipCode()) {
|
||||
|
||||
}else {
|
||||
$testStatus->setTrue('bork');
|
||||
$testStatus->setMessage('bork', $testFile->getExitMessage());
|
||||
$this->groupResults->setTestStatus($testFile->getTestName(), $testStatus);
|
||||
|
||||
//If there is some 'skip' code run it to see if the tests should be skipped and then do nothing else
|
||||
|
||||
$phpCommand = $this->runConfiguration->getSetting('PhpExecutable');
|
||||
$arguments = preg_replace('/error_reporting=32767/', 'error_reporting=0', $this->runConfiguration->getSetting('PhpCommandLineArguments'));
|
||||
|
||||
$phpCommand .= ' -f '.$this->groupConfiguration->getSkipFile();
|
||||
|
||||
$runner = new rtPhpRunner($phpCommand);
|
||||
$result = $runner->runphp();
|
||||
|
||||
|
||||
if (preg_match('/^\s*skip\s*(.+)\s*/i', $result, $matches)) {
|
||||
$this->groupResults->setSkip(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($this->isSkipGroup() !== true) {
|
||||
|
||||
$this->testFiles = rtUtil::getTestList($this->testDirectory);
|
||||
|
||||
$redirectFromID = $this->groupConfiguration->getRedirectFromID();
|
||||
|
||||
foreach ($this->testFiles as $testFileName) {
|
||||
//echo "\n" .memory_get_usage() . ", setup start". $testFileName . "\n";
|
||||
|
||||
//testFiles is a list of file names relative to the current working directory
|
||||
|
||||
if (!file_exists($testFileName)) {
|
||||
echo rtText::get('invalidTestFileName', array($testFileName));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Create a new test file object;
|
||||
$testFile = new rtPhpTestFile();
|
||||
$testFile->doRead($testFileName);
|
||||
$testFile->normaliseLineEndings();
|
||||
|
||||
//The test name is the full path to the test file name without the .phpt
|
||||
|
||||
$testStatus = new rtTestStatus($testFile->getTestName());
|
||||
if ($testFile->arePreconditionsMet() ) {
|
||||
// Create a new test case
|
||||
$this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus, $redirectFromID);
|
||||
} 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(), $this->runConfiguration, $testStatus);
|
||||
if($redirectedTest->hasSection('SKIPIF')) {
|
||||
$redirectedTest->runSkipif($this->runConfiguration);
|
||||
if($redirectedTest->getStatus()->getValue('skip')) {
|
||||
$testStatus->setTrue('skip');
|
||||
$testStatus->setMessage('skip', $testFile->getExitMessage(). ' and the skip condition has failed');
|
||||
$this->groupResults->setTestStatus($testFile->getTestName(), $testStatus);
|
||||
} else {
|
||||
$testStatus->setTrue('redirected');
|
||||
$testStatus->setMessage('redirected', $testFile->getExitMessage());
|
||||
$this->groupResults->setTestStatus($testFile->getTestName(), $testStatus);
|
||||
$this->groupResults->setRedirectedTestCase($redirectedTest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$testStatus->setTrue('bork');
|
||||
$testStatus->setMessage('bork', $testFile->getExitMessage());
|
||||
$this->groupResults->setTestStatus($testFile->getTestName(), $testStatus);
|
||||
|
||||
}
|
||||
|
||||
//echo "\n" .memory_get_usage() . ", setup complete". $testFileName . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$s=microtime(true);
|
||||
|
||||
$s=microtime(true);
|
||||
|
||||
if (count($this->testCases) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for($i=0; $i<count($this->testCases); $i++) {
|
||||
|
||||
$testCase = $this->testCases[$i];
|
||||
|
||||
$testCase = $this->testCases[$i];
|
||||
|
||||
$testCase->executeTest($this->runConfiguration);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$testResult = new rtTestResults($testCase);
|
||||
$testResult->processResults($testCase, $this->runConfiguration);
|
||||
$this->groupResults->setTestStatus($testCase->getName(), $testResult->getStatus());
|
||||
|
||||
|
||||
$this->groupResults->setTestStatus($testCase->getName(), $testResult->getStatus());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$e=microtime(true);
|
||||
|
||||
|
||||
$this->groupResults->setTime($e-$s);
|
||||
$this->groupResults->setAbsTime($e);
|
||||
}
|
||||
@@ -134,19 +158,23 @@ class rtPhpTestGroup extends rtTask implements rtTaskInterface
|
||||
$testOutputWriter = rtTestOutputWriter::getInstance($this->groupResults->getTestStatusList(), $outType);
|
||||
$testOutputWriter->write($this->testDirectory, $cid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getTestCases() {
|
||||
return $this->testCases;
|
||||
return $this->testCases;
|
||||
}
|
||||
|
||||
|
||||
public function getGroupName() {
|
||||
return $this->testDirectory;
|
||||
return $this->testDirectory;
|
||||
}
|
||||
|
||||
public function getGroupResults() {
|
||||
return $this->groupResults;
|
||||
|
||||
public function getGroupResults() {
|
||||
return $this->groupResults;
|
||||
}
|
||||
|
||||
|
||||
public function isSkipGroup() {
|
||||
return $this->groupResults->isSkipGroup();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -15,397 +15,410 @@
|
||||
*/
|
||||
class rtPhpTestRun
|
||||
{
|
||||
protected $commandLineArguments;
|
||||
protected $runConfiguration;
|
||||
protected $redirectedTestCases = array();
|
||||
protected $resultList = array(); //An array of arrays of Group Results
|
||||
protected $serialTasks = array();
|
||||
protected $parallelTasks = array();
|
||||
protected $reportStatus = 0;
|
||||
protected $numberOfSerialGroups = 0;
|
||||
protected $numberOfParallelGroups = 0;
|
||||
protected $processorCount;
|
||||
protected $runStartTime;
|
||||
protected $commandLineArguments;
|
||||
protected $runConfiguration;
|
||||
protected $redirectedTestCases = array();
|
||||
protected $resultList = array(); //An array of arrays of Group Results
|
||||
protected $serialTasks = array();
|
||||
protected $parallelTasks = array();
|
||||
protected $reportStatus = 0;
|
||||
protected $numberOfSerialGroups = 0;
|
||||
protected $numberOfParallelGroups = 0;
|
||||
protected $processorCount;
|
||||
protected $runStartTime;
|
||||
protected $skippedGroups = array();
|
||||
|
||||
public function __construct($argv)
|
||||
{
|
||||
$this->commandLineArguments = $argv;
|
||||
}
|
||||
public function __construct($argv)
|
||||
{
|
||||
$this->commandLineArguments = $argv;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$this->runStartTime = microtime(true);
|
||||
//Set SSH variables
|
||||
//Set SSH variables
|
||||
|
||||
// check the operation-system (win/unix)
|
||||
$os = (substr(PHP_OS, 0, 3) == "WIN") ? 'Windows' : 'Unix';
|
||||
|
||||
//Configure the test environment
|
||||
$this->runConfiguration = rtRuntestsConfiguration::getInstance($this->commandLineArguments, $os);
|
||||
$this->runConfiguration->getUserEnvironment();
|
||||
$this->runConfiguration->configure();
|
||||
|
||||
// check the operation-system (win/unix)
|
||||
$os = (substr(PHP_OS, 0, 3) == "WIN") ? 'Windows' : 'Unix';
|
||||
|
||||
//Configure the test environment
|
||||
$this->runConfiguration = rtRuntestsConfiguration::getInstance($this->commandLineArguments, $os);
|
||||
$this->runConfiguration->getUserEnvironment();
|
||||
$this->runConfiguration->configure();
|
||||
|
||||
|
||||
//Check help message
|
||||
if($this->runConfiguration->hasCommandLineOption('help') || $this->runConfiguration->hasCommandLineOption('h')) {
|
||||
echo rtText::get('help');
|
||||
exit;
|
||||
}
|
||||
|
||||
//Check the preconditions
|
||||
$preConditionList = rtPreConditionList::getInstance($os);
|
||||
$preConditionList->adaptList();
|
||||
//Check help message
|
||||
if($this->runConfiguration->hasCommandLineOption('help') || $this->runConfiguration->hasCommandLineOption('h')) {
|
||||
echo rtText::get('help');
|
||||
exit;
|
||||
}
|
||||
|
||||
// $preConditionList->check($this->commandLine, $this->environmentVariables);
|
||||
$preConditionList->check($this->runConfiguration);
|
||||
//Check the preconditions
|
||||
$preConditionList = rtPreConditionList::getInstance($os);
|
||||
$preConditionList->adaptList();
|
||||
|
||||
// $preConditionList->check($this->commandLine, $this->environmentVariables);
|
||||
$preConditionList->check($this->runConfiguration);
|
||||
|
||||
//Write PHP executable name to the array of env variables. Some
|
||||
//test cases expect to be able to use it.
|
||||
$php = $this->runConfiguration->getSetting('PhpExecutable');
|
||||
$this->runConfiguration->setEnvironmentVariable('TEST_PHP_EXECUTABLE', $php);
|
||||
|
||||
//Set reporting option
|
||||
$this->setReportStatus();
|
||||
|
||||
$this->processorCount = $this->requestedProcessorCount();
|
||||
|
||||
//Write PHP executable name to the array of env variables. Some
|
||||
//test cases expect to be able to use it.
|
||||
$php = $this->runConfiguration->getSetting('PhpExecutable');
|
||||
$this->runConfiguration->setEnvironmentVariable('TEST_PHP_EXECUTABLE', $php);
|
||||
|
||||
//Set reporting option
|
||||
$this->setReportStatus();
|
||||
|
||||
$this->processorCount = $this->requestedProcessorCount();
|
||||
|
||||
|
||||
/*
|
||||
* Main decision point. Either we start this with a directory (or set of directories, in which case tests are
|
||||
* 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->doGroupRuns();
|
||||
|
||||
} 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');
|
||||
exit();
|
||||
}else{
|
||||
$this->run_tests($this->runConfiguration->getSetting('TestFiles'));
|
||||
}
|
||||
}
|
||||
*/
|
||||
if ($this->runConfiguration->getSetting('TestDirectories') != null) {
|
||||
|
||||
$this->doGroupRuns();
|
||||
|
||||
} 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');
|
||||
exit();
|
||||
}else{
|
||||
$this->run_tests($this->runConfiguration->getSetting('TestFiles'));
|
||||
}
|
||||
}
|
||||
|
||||
if(count($this->redirectedTestCases) > 0) {
|
||||
$this->doRedirectedRuns();
|
||||
}
|
||||
|
||||
if(($this->numberOfSerialGroups != 0) || ($this->numberOfParallelGroups != 0)) {
|
||||
$this->createRunOutput();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function doGroupRuns() {
|
||||
|
||||
$subDirectories = $this->buildSubDirectoryList($this->runConfiguration->getSetting('TestDirectories'));
|
||||
$groupConfigurations = $this->buildGroupConfigurations($subDirectories);
|
||||
if(count($this->redirectedTestCases) > 0) {
|
||||
$this->doRedirectedRuns();
|
||||
}
|
||||
|
||||
if(($this->numberOfSerialGroups != 0) || ($this->numberOfParallelGroups != 0)) {
|
||||
$this->createRunOutput();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//If there is only one subdirectory, run seqential
|
||||
public function doGroupRuns() {
|
||||
|
||||
if(count($subDirectories) === 1) {
|
||||
$this->run_serial_groups($subDirectories, $groupConfigurations);
|
||||
$this->numberOfSerialGroups = 1;
|
||||
|
||||
} else {
|
||||
|
||||
//check to see if this is set to be a parallel run, if not, run the subdirectory groups in sequence.
|
||||
if($this->processorCount <= 1) {
|
||||
$this->run_serial_groups($subDirectories, $groupConfigurations);
|
||||
$this->numberOfSerialGroups = count($subDirectories);
|
||||
} else {
|
||||
//At least part of this run can be in parallel, check group configurations to make sure that none are set to be serial.
|
||||
//This builds parallel and serial task lists.
|
||||
foreach($groupConfigurations as $key=>$gc) {
|
||||
if($gc->isSerial()) {
|
||||
$serialGroups[] = $key;
|
||||
} else {
|
||||
$parallelGroups[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($serialGroups)) {$this->numberOfSerialGroups = count($serialGroups);}
|
||||
|
||||
$this->numberOfParallelGroups = count($parallelGroups);
|
||||
|
||||
$this->run_parallel_groups($parallelGroups, $groupConfigurations, $this->processorCount);
|
||||
if($this->numberOfSerialGroups > 0) {
|
||||
$this->run_serial_groups($serialGroups, $groupConfigurations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function doRedirectedRuns() {
|
||||
foreach($this->redirectedTestCases as $testCase){
|
||||
|
||||
$groupConfig = new rtGroupConfiguration(null);
|
||||
$groupConfig->parseRedirect($testCase);
|
||||
|
||||
$group = $groupConfig->getTestDirectory();
|
||||
|
||||
$this->run_serial_groups(array($group), array($group=>$groupConfig));
|
||||
|
||||
$this->numberOfSerialGroups++;
|
||||
|
||||
}
|
||||
}
|
||||
$subDirectories = $this->buildSubDirectoryList($this->runConfiguration->getSetting('TestDirectories'));
|
||||
|
||||
//An array of group configuration objects, one for each subdirectory.
|
||||
$groupConfigurations = $this->buildGroupConfigurations($subDirectories);
|
||||
|
||||
public function run_parallel_groups($testDirectories, $groupConfigurations, $processCount) {
|
||||
|
||||
// create the task-list
|
||||
$taskList = array();
|
||||
foreach($testDirectories as $testGroup) {
|
||||
$taskList[] = new rtTaskTestGroup($this->runConfiguration, $testGroup, $groupConfigurations[$testGroup]);
|
||||
}
|
||||
|
||||
// run the task-scheduler
|
||||
$scheduler = rtTaskScheduler::getInstance();
|
||||
$scheduler->setTaskList($taskList);
|
||||
$scheduler->setProcessCount($processCount);
|
||||
$scheduler->setReportStatus($this->reportStatus);
|
||||
$scheduler->run();
|
||||
//If there is only one subdirectory, run seqential
|
||||
|
||||
foreach($scheduler->getResultList() as $groupResult) {
|
||||
|
||||
$this->resultList[] = $groupResult->getTestStatusList();
|
||||
|
||||
// Debug - get which group was run by which processor and how long each took
|
||||
//
|
||||
|
||||
if($this->runConfiguration->hasCommandLineOption('debug')) {
|
||||
$time = round($groupResult->getTime(), 2);
|
||||
|
||||
$absTime = $groupResult->getAbsTime() - $this->runStartTime;
|
||||
|
||||
$absTime = round($absTime, 2);
|
||||
|
||||
echo "\nPARDBG," . $absTime. "," . $time . "," . $groupResult->getProcessorId() . "," . $groupResult->getRunOrder() . "," . $groupResult->getGroupName();
|
||||
if(count($subDirectories) === 1) {
|
||||
$this->run_serial_groups($subDirectories, $groupConfigurations);
|
||||
$this->numberOfSerialGroups = 1;
|
||||
|
||||
}
|
||||
|
||||
$redirects = $groupResult->getRedirectedTestCases();
|
||||
foreach($redirects as $testCase) {
|
||||
$this->redirectedTestCases[] = $testCase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function run_serial_groups($testDirectories, $groupConfigurations) {
|
||||
|
||||
$count = 0;
|
||||
|
||||
|
||||
//xdebug_start_trace('/tmp/memorycheck');
|
||||
|
||||
foreach($testDirectories as $subDirectory) {
|
||||
|
||||
|
||||
|
||||
|
||||
// Memory usage debugging
|
||||
//$startm = memory_get_usage();
|
||||
|
||||
|
||||
$testGroup = new rtPhpTestGroup($this->runConfiguration, $subDirectory, $groupConfigurations[$subDirectory]);
|
||||
$testGroup->run();
|
||||
|
||||
// Memory usage debugging
|
||||
//$midm = memory_get_usage();
|
||||
} else {
|
||||
|
||||
|
||||
rtTestOutputWriter::flushResult($testGroup->getGroupResults()->getTestStatusList(), $this->reportStatus);
|
||||
$this->resultList[] = $testGroup->getGroupResults()->getTestStatusList();
|
||||
|
||||
if($this->runConfiguration->hasCommandLineOption('debug')) {
|
||||
|
||||
$time = round($testGroup->getGroupResults()->getTime(), 2);
|
||||
|
||||
$absTime = ($testGroup->getGroupResults()->getAbsTime()) - $this->runStartTime;
|
||||
$absTime = round($absTime, 2);
|
||||
|
||||
|
||||
echo "\nSERDBG," . $absTime . "," . $time . "," . $testGroup->getGroupResults()->getProcessorId() . "," . $count . "," . $testGroup->getGroupResults()->getGroupName();
|
||||
//check to see if this is set to be a parallel run, if not, run the subdirectory groups in sequence.
|
||||
if($this->processorCount <= 1) {
|
||||
$this->run_serial_groups($subDirectories, $groupConfigurations);
|
||||
$this->numberOfSerialGroups = count($subDirectories);
|
||||
} else {
|
||||
//At least part of this run can be in parallel, check group configurations to make sure that none are set to be serial.
|
||||
//This builds parallel and serial task lists.
|
||||
foreach($groupConfigurations as $key=>$gc) {
|
||||
if($gc->isSerial()) {
|
||||
$serialGroups[] = $key;
|
||||
} else {
|
||||
$parallelGroups[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($serialGroups)) {$this->numberOfSerialGroups = count($serialGroups);}
|
||||
|
||||
$this->numberOfParallelGroups = count($parallelGroups);
|
||||
|
||||
$this->run_parallel_groups($parallelGroups, $groupConfigurations, $this->processorCount);
|
||||
if($this->numberOfSerialGroups > 0) {
|
||||
$this->run_serial_groups($serialGroups, $groupConfigurations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Memory usage debugging
|
||||
//$midm2 = memory_get_usage();
|
||||
|
||||
$redirects = $testGroup->getGroupResults()->getRedirectedTestCases();
|
||||
foreach($redirects as $testCase) {
|
||||
$this->redirectedTestCases[] = $testCase;
|
||||
}
|
||||
|
||||
// Memory usage debugging
|
||||
//$midm3 = memory_get_usage();
|
||||
|
||||
|
||||
$testGroup->__destruct();
|
||||
unset($testGroup);
|
||||
|
||||
// Memory usage debugging
|
||||
//echo "\n" . $startm . ", " . $midm. ", " .$midm2. ", " .$midm3. ", " .memory_get_usage() . ", ". $subDirectory . "\n";
|
||||
$count++;
|
||||
}
|
||||
|
||||
//xdebug_stop_trace();
|
||||
}
|
||||
|
||||
public function run_tests($testNames) {
|
||||
}
|
||||
|
||||
//This section deals with running single test cases, or lists of test cases.
|
||||
public function doRedirectedRuns() {
|
||||
foreach($this->redirectedTestCases as $testCase){
|
||||
|
||||
$groupConfig = new rtGroupConfiguration(null);
|
||||
$groupConfig->parseRedirect($testCase);
|
||||
|
||||
$group = $groupConfig->getTestDirectory();
|
||||
|
||||
$this->run_serial_groups(array($group), array($group=>$groupConfig));
|
||||
|
||||
$this->numberOfSerialGroups++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($testNames as $testName) {
|
||||
public function run_parallel_groups($testDirectories, $groupConfigurations, $processCount) {
|
||||
|
||||
if (!file_exists($testName)) {
|
||||
echo rtText::get('invalidTestFileName', array($testName));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//Read the test file
|
||||
$testFile = new rtPhpTestFile();
|
||||
$testFile->doRead($testName);
|
||||
$testFile->normaliseLineEndings();
|
||||
|
||||
$testStatus = new rtTestStatus($testFile->getTestName());
|
||||
|
||||
// create the task-list
|
||||
$taskList = array();
|
||||
foreach($testDirectories as $testGroup) {
|
||||
$taskList[] = new rtTaskTestGroup($this->runConfiguration, $testGroup, $groupConfigurations[$testGroup]);
|
||||
}
|
||||
|
||||
if ($testFile->arePreconditionsMet()) {
|
||||
$testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
|
||||
|
||||
//Setup and set the local environment for the test case
|
||||
$testCase->executeTest($this->runConfiguration);
|
||||
// run the task-scheduler
|
||||
$scheduler = rtTaskScheduler::getInstance();
|
||||
$scheduler->setTaskList($taskList);
|
||||
$scheduler->setProcessCount($processCount);
|
||||
$scheduler->setReportStatus($this->reportStatus);
|
||||
$scheduler->run();
|
||||
|
||||
$results = new rtTestResults($testCase);
|
||||
$results->processResults($testCase, $this->runConfiguration);
|
||||
$summaryResults = array($testFile->getTestName() => $results->getStatus());
|
||||
foreach($scheduler->getResultList() as $groupResult) {
|
||||
|
||||
if($groupResult->isSkipGroup()) {
|
||||
$this->skippedGroups[] = $groupResult->getGroupName();
|
||||
} else {
|
||||
$this->resultList[] = $groupResult->getTestStatusList();
|
||||
}
|
||||
|
||||
} elseif (in_array("REDIRECTTEST", $testFile->getSectionHeadings())) {
|
||||
|
||||
//Redirect handler
|
||||
//Build a list of redirected test cases
|
||||
|
||||
$this->redirectedTestCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
|
||||
|
||||
$testStatus->setTrue('redirected');
|
||||
$testStatus->setMessage('redirected', $testFile->getExitMessage());
|
||||
$summaryResults = array($testFile->getTestName() => $testStatus);
|
||||
|
||||
} else {
|
||||
$testStatus->setTrue('bork');
|
||||
$testStatus->setMessage('bork', $testFile->getExitMessage());
|
||||
$summaryResults = array($testFile->getTestName() => $testStatus);
|
||||
}
|
||||
// Debug - get which group was run by which processor and how long each took
|
||||
//
|
||||
|
||||
if($this->runConfiguration->hasCommandLineOption('debug')) {
|
||||
$time = round($groupResult->getTime(), 2);
|
||||
|
||||
$absTime = $groupResult->getAbsTime() - $this->runStartTime;
|
||||
|
||||
$absTime = round($absTime, 2);
|
||||
|
||||
echo "\nPARDBG," . $absTime. "," . $time . "," . $groupResult->getProcessorId() . "," . $groupResult->getRunOrder() . "," . $groupResult->getGroupName();
|
||||
|
||||
}
|
||||
|
||||
$redirects = $groupResult->getRedirectedTestCases();
|
||||
foreach($redirects as $testCase) {
|
||||
$this->redirectedTestCases[] = $testCase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function run_serial_groups($testDirectories, $groupConfigurations) {
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach($testDirectories as $subDirectory) {
|
||||
|
||||
// Memory usage debugging
|
||||
//$startm = memory_get_usage();
|
||||
|
||||
|
||||
|
||||
$testGroup = new rtPhpTestGroup($this->runConfiguration, $subDirectory, $groupConfigurations[$subDirectory]);
|
||||
|
||||
rtTestOutputWriter::flushResult($summaryResults, 3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function buildSubDirectoryList($testDirectories){
|
||||
|
||||
|
||||
$subDirectories = array();
|
||||
foreach ($testDirectories as $testDirectory) {
|
||||
$subDirectories = array_merge($subDirectories, rtUtil::parseDir($testDirectory));
|
||||
}
|
||||
return $subDirectories;
|
||||
}
|
||||
|
||||
public function requestedProcessorCount() {
|
||||
// check for the cmd-line-option 'z' which defines parellel-execution
|
||||
$processCount = 0;
|
||||
if ($this->runConfiguration->hasCommandLineOption('z')) {
|
||||
|
||||
$processCount = intval($this->runConfiguration->getCommandLineOption('z'));
|
||||
|
||||
if (!is_numeric($processCount) || $processCount < 0) {
|
||||
$processCount = 2;
|
||||
}
|
||||
}
|
||||
return $processCount;
|
||||
}
|
||||
|
||||
public function buildGroupConfigurations($subDirectories) {
|
||||
$groupConfigurations = array();
|
||||
foreach($subDirectories as $subDir) {
|
||||
$groupConfig = new rtGroupConfiguration($subDir);
|
||||
$groupConfig->parse();
|
||||
$groupConfigurations[$subDir] = $groupConfig;
|
||||
}
|
||||
return $groupConfigurations;
|
||||
}
|
||||
|
||||
if($testGroup->isSkipGroup() == true) {
|
||||
$this->skippedGroups[] = $testGroup->getGroupName();
|
||||
} else {
|
||||
|
||||
|
||||
public function buildRedirectsList($results) {
|
||||
foreach ($results as $groupResult) {
|
||||
foreach($groupResult as $testResult) {
|
||||
if($testResult->getStatus() == 'redirected') {
|
||||
$this->redirectedTestCases[] = $testResult->getRedirectedTestCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createRunOutput() {
|
||||
$type = null;
|
||||
if ($this->runConfiguration->hasCommandLineOption('o')) {
|
||||
$type = $this->runConfiguration->getCommandLineOption('o');
|
||||
}
|
||||
|
||||
$outputWriter = rtTestOutputWriter::getInstance($type);
|
||||
$outputWriter->setResultList($this->resultList);
|
||||
|
||||
$outputWriter->printOverview($this->numberOfParallelGroups, $this->numberOfSerialGroups, $this->processorCount);
|
||||
$testGroup->run();
|
||||
|
||||
|
||||
// Memory usage debugging
|
||||
//$midm = memory_get_usage();
|
||||
|
||||
rtTestOutputWriter::flushResult($testGroup->getGroupResults()->getTestStatusList(), $this->reportStatus);
|
||||
$this->resultList[] = $testGroup->getGroupResults()->getTestStatusList();
|
||||
|
||||
if($this->runConfiguration->hasCommandLineOption('debug')) {
|
||||
|
||||
$time = round($testGroup->getGroupResults()->getTime(), 2);
|
||||
|
||||
$absTime = ($testGroup->getGroupResults()->getAbsTime()) - $this->runStartTime;
|
||||
$absTime = round($absTime, 2);
|
||||
|
||||
|
||||
echo "\nSERDBG," . $absTime . "," . $time . "," . $testGroup->getGroupResults()->getProcessorId() . "," . $count . "," . $testGroup->getGroupResults()->getGroupName();
|
||||
|
||||
}
|
||||
|
||||
// Memory usage debugging
|
||||
//$midm2 = memory_get_usage();
|
||||
|
||||
$redirects = $testGroup->getGroupResults()->getRedirectedTestCases();
|
||||
foreach($redirects as $testCase) {
|
||||
$this->redirectedTestCases[] = $testCase;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Memory usage debugging
|
||||
//$midm3 = memory_get_usage();
|
||||
|
||||
|
||||
$testGroup->__destruct();
|
||||
unset($testGroup);
|
||||
|
||||
// Memory usage debugging
|
||||
//echo "\n" . $startm . ", " . $midm. ", " .$midm2. ", " .$midm3. ", " .memory_get_usage() . ", ". $subDirectory . "\n";
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
//xdebug_stop_trace();
|
||||
}
|
||||
|
||||
public function run_tests($testNames) {
|
||||
|
||||
//This section deals with running single test cases, or lists of test cases.
|
||||
|
||||
foreach ($testNames as $testName) {
|
||||
|
||||
if (!file_exists($testName)) {
|
||||
echo rtText::get('invalidTestFileName', array($testName));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//Read the test file
|
||||
$testFile = new rtPhpTestFile();
|
||||
$testFile->doRead($testName);
|
||||
$testFile->normaliseLineEndings();
|
||||
|
||||
$testStatus = new rtTestStatus($testFile->getTestName());
|
||||
|
||||
|
||||
if ($testFile->arePreconditionsMet()) {
|
||||
$testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
|
||||
|
||||
//Setup and set the local environment for the test case
|
||||
$testCase->executeTest($this->runConfiguration);
|
||||
|
||||
$results = new rtTestResults($testCase);
|
||||
$results->processResults($testCase, $this->runConfiguration);
|
||||
$summaryResults = array($testFile->getTestName() => $results->getStatus());
|
||||
|
||||
} elseif (in_array("REDIRECTTEST", $testFile->getSectionHeadings())) {
|
||||
|
||||
//Redirect handler
|
||||
//Build a list of redirected test cases
|
||||
|
||||
$this->redirectedTestCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $this->runConfiguration, $testStatus);
|
||||
|
||||
$testStatus->setTrue('redirected');
|
||||
$testStatus->setMessage('redirected', $testFile->getExitMessage());
|
||||
$summaryResults = array($testFile->getTestName() => $testStatus);
|
||||
|
||||
} else {
|
||||
$testStatus->setTrue('bork');
|
||||
$testStatus->setMessage('bork', $testFile->getExitMessage());
|
||||
$summaryResults = array($testFile->getTestName() => $testStatus);
|
||||
}
|
||||
|
||||
rtTestOutputWriter::flushResult($summaryResults, 3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function buildSubDirectoryList($testDirectories){
|
||||
|
||||
|
||||
$subDirectories = array();
|
||||
foreach ($testDirectories as $testDirectory) {
|
||||
$subDirectories = array_merge($subDirectories, rtUtil::parseDir($testDirectory));
|
||||
}
|
||||
return $subDirectories;
|
||||
}
|
||||
|
||||
public function requestedProcessorCount() {
|
||||
// check for the cmd-line-option 'z' which defines parellel-execution
|
||||
$processCount = 0;
|
||||
if ($this->runConfiguration->hasCommandLineOption('z')) {
|
||||
|
||||
$processCount = intval($this->runConfiguration->getCommandLineOption('z'));
|
||||
|
||||
if (!is_numeric($processCount) || $processCount < 0) {
|
||||
$processCount = 2;
|
||||
}
|
||||
}
|
||||
return $processCount;
|
||||
}
|
||||
|
||||
public function buildGroupConfigurations($subDirectories) {
|
||||
$groupConfigurations = array();
|
||||
foreach($subDirectories as $subDir) {
|
||||
$groupConfig = new rtGroupConfiguration($subDir);
|
||||
$groupConfig->parseConfiguration();
|
||||
$groupConfigurations[$subDir] = $groupConfig;
|
||||
}
|
||||
return $groupConfigurations;
|
||||
}
|
||||
|
||||
public function buildRedirectsList($results) {
|
||||
foreach ($results as $groupResult) {
|
||||
foreach($groupResult as $testResult) {
|
||||
if($testResult->getStatus() == 'redirected') {
|
||||
$this->redirectedTestCases[] = $testResult->getRedirectedTestCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createRunOutput() {
|
||||
$type = null;
|
||||
if ($this->runConfiguration->hasCommandLineOption('o')) {
|
||||
$type = $this->runConfiguration->getCommandLineOption('o');
|
||||
}
|
||||
|
||||
$outputWriter = rtTestOutputWriter::getInstance($type);
|
||||
$outputWriter->setResultList($this->resultList);
|
||||
|
||||
$outputWriter->printOverview($this->numberOfParallelGroups, $this->numberOfSerialGroups, $this->processorCount, $this->skippedGroups);
|
||||
|
||||
$filename = null;
|
||||
if ($this->runConfiguration->hasCommandLineOption('s')) {
|
||||
$filename = $this->runConfiguration->getCommandLineOption('s');
|
||||
}
|
||||
|
||||
if ($type || $filename) {
|
||||
$outputWriter->write($filename);
|
||||
}
|
||||
}
|
||||
|
||||
public function setReportStatus() {
|
||||
// check for the cmd-line-option 'v' which defines the report-status
|
||||
if ($this->runConfiguration->hasCommandLineOption('v')) {
|
||||
$this->reportStatus = 1;
|
||||
} else if ($this->runConfiguration->hasCommandLineOption('vv')) {
|
||||
$this->reportStatus = 2;
|
||||
} else if ($this->runConfiguration->hasCommandLineOption('vvv')) {
|
||||
$this->reportStatus = 3;
|
||||
}
|
||||
|
||||
//Set the default for runs from 'make test'
|
||||
if ( file_exists(getcwd() . "/sapi/cli/php")) {
|
||||
$this->reportStatus = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function extractResults($groupResult) {
|
||||
$groupSummary = array();
|
||||
foreach($groupResult as $testResult) {
|
||||
$groupSummary[$testResult->getName()] = $testResult->getStatus();
|
||||
if($testResult->getStatus() == 'redirected') {
|
||||
$this->redirectedTestCases[] = $testResult->getRedirectedTestCase();
|
||||
}
|
||||
}
|
||||
return $groupSummary;
|
||||
}
|
||||
|
||||
$filename = null;
|
||||
if ($this->runConfiguration->hasCommandLineOption('s')) {
|
||||
$filename = $this->runConfiguration->getCommandLineOption('s');
|
||||
}
|
||||
|
||||
if ($type || $filename) {
|
||||
$outputWriter->write($filename);
|
||||
}
|
||||
}
|
||||
|
||||
public function setReportStatus() {
|
||||
// check for the cmd-line-option 'v' which defines the report-status
|
||||
if ($this->runConfiguration->hasCommandLineOption('v')) {
|
||||
$this->reportStatus = 1;
|
||||
} else if ($this->runConfiguration->hasCommandLineOption('vv')) {
|
||||
$this->reportStatus = 2;
|
||||
} else if ($this->runConfiguration->hasCommandLineOption('vvv')) {
|
||||
$this->reportStatus = 3;
|
||||
}
|
||||
|
||||
//Set the default for runs from 'make test'
|
||||
if ( file_exists(getcwd() . "/sapi/cli/php")) {
|
||||
$this->reportStatus = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function extractResults($groupResult) {
|
||||
$groupSummary = array();
|
||||
foreach($groupResult as $testResult) {
|
||||
$groupSummary[$testResult->getName()] = $testResult->getStatus();
|
||||
if($testResult->getStatus() == 'redirected') {
|
||||
$this->redirectedTestCases[] = $testResult->getRedirectedTestCase();
|
||||
}
|
||||
}
|
||||
return $groupSummary;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -3,12 +3,26 @@ require_once dirname(__FILE__) . '/../src/rtAutoload.php';
|
||||
require_once dirname(__FILE__) . '/rtTestBootstrap.php';
|
||||
|
||||
class rtGroupConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
{
|
||||
protected $path_to_group;
|
||||
|
||||
public function setUp() {
|
||||
$this->path_to_group = realpath(dirname(__FILE__) . '/../phpt-tests/group_of_tests');
|
||||
}
|
||||
|
||||
public function testCreateInstance()
|
||||
{
|
||||
//$directory = realpath(dirname(__FILE__) . '/../phpt-tests');
|
||||
$config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', RT_PHP_PATH, 'testgroup'));
|
||||
|
||||
$config->configure();
|
||||
$config->configure();
|
||||
|
||||
$groupConfig = new rtGroupConfiguration($this->path_to_group);
|
||||
|
||||
$groupConfig->parseConfiguration();
|
||||
|
||||
$this->assertTrue(file_exists($groupConfig->getSkipFile()));
|
||||
$this->assertTrue($groupConfig->hasSkipCode());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,20 @@ class rtPHpTestGroupTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testSkipGroup() {
|
||||
$directory = realpath(dirname(__FILE__) . '/../phpt-tests/group_of_tests');
|
||||
$run_config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', RT_PHP_PATH, $directory));
|
||||
|
||||
$run_config->configure();
|
||||
|
||||
$group_config = new rtGroupConfiguration($directory);
|
||||
$group_config->parseConfiguration();
|
||||
|
||||
$phpTestGroup = new rtPhpTestGroup($run_config, $directory, $group_config);
|
||||
$phpTestGroup->init();
|
||||
|
||||
$this->assertTrue($phpTestGroup->isSkipGroup());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user