Commit:    b668d1f0fec05a87f29f2aa9601203228b123916
Author:    zoe slattery <z...@php.net>         Thu, 11 Oct 2012 16:56:28 +0100
Parents:   b3d8d59065990541c66cad5e84ba0d0c836684c2
Branches:  master

Link:       
http://git.php.net/?p=phpruntests.git;a=commitdiff;h=b668d1f0fec05a87f29f2aa9601203228b123916

Log:
Some changes to reduce memory usage

Changed paths:
  M  src/run-tests.php
  M  src/taskScheduler/rtTaskTestGroup.php
  M  src/testcase/output/rtTestOutputWriterCSV.php
  M  src/testcase/output/rtTestOutputWriterHTML.php
  M  src/testcase/output/rtTestOutputWriterList.php
  M  src/testcase/output/rtTestOutputWriterXML.php
  M  src/testcase/rtPhpTest.php
  M  src/testcase/rtTestOutputWriter.php
  M  src/testcase/rtTestResults.php
  M  src/testcase/rtTestStatus.php
  M  src/testgroup/rtPhpTestGroup.php
  M  src/testrun/rtPhpTestRun.php
  M  tests/rtPhpTestGroupTest.php

diff --git a/src/run-tests.php b/src/run-tests.php
index 3adb55f..3d11d00 100644
--- a/src/run-tests.php
+++ b/src/run-tests.php
@@ -33,7 +33,6 @@ if (version_compare(PHP_VERSION, '5.3.0RC1', '<')) {
 require_once dirname(__FILE__) . '/rtAutoload.php';
 
 $s = microtime(true);
-var_dump($argv);
 
 $phpTestRun = new rtPhpTestRun($argv);
 $phpTestRun->run();
diff --git a/src/taskScheduler/rtTaskTestGroup.php 
b/src/taskScheduler/rtTaskTestGroup.php
index 8509caa..d0a2910 100644
--- a/src/taskScheduler/rtTaskTestGroup.php
+++ b/src/taskScheduler/rtTaskTestGroup.php
@@ -36,6 +36,10 @@ class rtTaskTestGroup extends rtTask implements 
rtTaskInterface
                $testGroup = new rtPhpTestGroup($this->runConfiguration, 
$this->subDirectory, $this->groupConfig);
                $testGroup->run();
         $this->result = $testGroup->getResults();
+        
+        $testGroup->__destruct();
+        unset($testGroup);
+               
                return true;
        }
 
diff --git a/src/testcase/output/rtTestOutputWriterCSV.php 
b/src/testcase/output/rtTestOutputWriterCSV.php
index 725dc81..b0e48c9 100644
--- a/src/testcase/output/rtTestOutputWriterCSV.php
+++ b/src/testcase/output/rtTestOutputWriterCSV.php
@@ -27,14 +27,14 @@ class rtTestOutputWriterCSV extends rtTestOutputWriter
     {
        foreach ($this->resultList as $testGroupResults) {
                
-               foreach ($testGroupResults as $testResult) {
+               foreach ($testGroupResults as $testName=>$status) {
                    
-                       $outputString = $testResult->getName();
-                   $testStatus = $testResult->getStatus();
+                       $outputString = $testName;
                    
-                   foreach($testStatus->getTestStateNames() as $name) {
+                   
+                   foreach($status->getTestStateNames() as $name) {
                        
-                       if($testStatus->getValue($name)) {
+                       if($status->getValue($name)) {
                            $outputString .= " , ". strtoupper($name);
                        }
                    }
diff --git a/src/testcase/output/rtTestOutputWriterHTML.php 
b/src/testcase/output/rtTestOutputWriterHTML.php
index b4e6e3d..34fb3b9 100644
--- a/src/testcase/output/rtTestOutputWriterHTML.php
+++ b/src/testcase/output/rtTestOutputWriterHTML.php
@@ -73,19 +73,19 @@ class rtTestOutputWriterHTML extends rtTestOutputWriter
                $tbody = $this->dom->createElement('tbody');
                $table->appendChild($tbody);
                
-               foreach ($testGroupResults as $testResult) {
+               foreach ($testGroupResults as $testName => $testStatus) {
 
                        $tr = $this->dom->createElement('tr');
                        $tbody->appendChild($tr);
 
                        // name
-                       $td = $this->dom->createElement('td', 
$testResult->getName());
+                       $td = $this->dom->createElement('td', $testName);
                        $td->setAttribute('class', 'mainCol');
                        $tr->appendChild($td);
 
                        // status
-                       $status = $testResult->getStatus();
-                       $s = $status->__toString();
+                       
+                       $s = $testStatus->__toString();
                        
                        $td = $this->dom->createElement('td', strtoupper($s));
                        $td->setAttribute('class', $s);
diff --git a/src/testcase/output/rtTestOutputWriterList.php 
b/src/testcase/output/rtTestOutputWriterList.php
index 27e0b0b..2ca8958 100644
--- a/src/testcase/output/rtTestOutputWriterList.php
+++ b/src/testcase/output/rtTestOutputWriterList.php
@@ -26,10 +26,10 @@ class rtTestOutputWriterList extends rtTestOutputWriter
     {
         foreach ($this->resultList as $testGroupResults) {
                
-               foreach ($testGroupResults as $testResult) {
+               foreach ($testGroupResults as $testName => $testStatus) {
 
                    $outputString = "";
-                   $testStatus = $testResult->getStatus();
+                   
                    
                    foreach($testStatus->getTestStateNames() as $name) {
 
@@ -39,8 +39,8 @@ class rtTestOutputWriterList extends rtTestOutputWriter
                        }
                    }
                    
-                   $outputString .= " " . $testResult->getTitle();
-                   $outputString .= " [" . $testResult->getName() . ".phpt]";
+                   
+                   $outputString .= " [" . $testName . ".phpt]";
                    $this->output .= $outputString."\n";
                }
         }
diff --git a/src/testcase/output/rtTestOutputWriterXML.php 
b/src/testcase/output/rtTestOutputWriterXML.php
index daa54de..e4c3d7d 100644
--- a/src/testcase/output/rtTestOutputWriterXML.php
+++ b/src/testcase/output/rtTestOutputWriterXML.php
@@ -49,33 +49,26 @@ class rtTestOutputWriterXML extends rtTestOutputWriter
 
                $state = array();
                
-               foreach ($testGroupResults as $testResult) {
+               foreach ($testGroupResults as $testName => $testStatus) {
        
                        // create test-node
                        $testNode = $this->dom->createElement('testcase');
                        $groupNode->appendChild($testNode);
 
                        // name
-                       $n = explode($wdir, $testResult->getName());
+                       $n = explode($wdir, $testName);
                        $n = explode('/', $n[1]);
                        $n = array_pop($n);
                        $testNode->setAttribute('name', $n);
                                
                        // status
-                       $status = $testResult->getStatus();
-                       $s = $status->__toString();
+                       
+                       $s = $testStatus->__toString();
                                $testNode->setAttribute('status', 
strtoupper($s));
-               
-                       // title
-                   $title = $testResult->getTitle();
-
-                       if (strlen($title) > 0) {
-                               $titleNode = $this->dom->createElement('title', 
utf8_encode(htmlentities($title)));
-                               $testNode->appendChild($titleNode);
-                       }
+       
                                
                                // message
-                   $msg = $status->getMessage($s);
+                   $msg = $testStatus->getMessage($s);
 
                        if (!is_null($msg)) {
                                $msgNode = $this->dom->createElement('message', 
utf8_encode(htmlentities($msg)));
@@ -83,7 +76,7 @@ class rtTestOutputWriterXML extends rtTestOutputWriter
                        }
                        
                        // files
-                       $files = $testResult->getSavedFileNames();
+                       $files = $testStatus->getSavedFileNames();
                                        
                                if (sizeof($files) > 0) {
                                        
@@ -107,22 +100,6 @@ class rtTestOutputWriterXML extends rtTestOutputWriter
                
                $global_count += sizeof($testGroupResults);
 
-               // add group-node attributes
-
-               $n = explode($wdir, $testGroupResults[0]->getName());
-               $n = explode('/', $n[1]);
-               array_pop($n);
-               $n = implode('/', $n);
-               
-               $groupNode->setAttribute('name', $n);
-               $groupNode->setAttribute('tests', sizeof($testGroupResults));
-               
-               $time = round($testGroupResults[0]->getTime(), 2);
-               $groupNode->setAttribute('time', $time);
-               
-               foreach ($state as $k => $v) {
-                       $groupNode->setAttribute($k, $v);
-               }
        }
         
        $this->dom->encoding = 'UTF-8';
diff --git a/src/testcase/rtPhpTest.php b/src/testcase/rtPhpTest.php
index 9febda7..852368e 100644
--- a/src/testcase/rtPhpTest.php
+++ b/src/testcase/rtPhpTest.php
@@ -20,7 +20,7 @@ class rtPhpTest
     protected $contents;
     protected $testStatus;
     protected $output;
-    protected $sections;
+    protected $sections = array();
     protected $fileSection;
     protected $expectSection;
     protected $sectionHeadings;
@@ -137,8 +137,8 @@ class rtPhpTest
     }
     /**
      * 
-     * Just runs teh SKIPIF section - required for redirect test implementation
-     * @param $runConfiguration
+     * Just runs the SKIPIF section - required for redirect test implementation
+     * @param $runConfiguration... hmm, should have a testconfiguration?
      */
     
     public function runSkipif(rtRuntestsConfiguration $runConfiguration) {    
diff --git a/src/testcase/rtTestOutputWriter.php 
b/src/testcase/rtTestOutputWriter.php
index 8cb23ac..99e1ac7 100644
--- a/src/testcase/rtTestOutputWriter.php
+++ b/src/testcase/rtTestOutputWriter.php
@@ -118,8 +118,8 @@ abstract class rtTestOutputWriter
        $count = 0;
        
        foreach ($this->resultList as $groupResult) { 
-               foreach($groupResult as $testResult) {                  
-                               $s = $testResult->getStatus()->__toString();
+               foreach($groupResult as $name=>$testStatus) {                   
+                               $s = $testStatus->__toString();
                                
                                if (!isset($state[$s])) {
                                        $state[$s] = 0;
@@ -211,6 +211,7 @@ abstract class rtTestOutputWriter
      */
     public static function flushResult(array $results, $state=0, $cid=NULL)
     {
+    
        switch ($state) {
 
                case -1:        // no ouput
@@ -227,27 +228,26 @@ abstract class rtTestOutputWriter
 
                case 1:         // every test-case incl. status
                        print "\n";
-                               foreach ($results as $result) {
-                                       print 
strtoupper($result->getStatus())."\t".$result->getName()."\n";
+                               foreach ($results as $name=>$status) {
+                                       print 
strtoupper($status->__toString())."\t".$name."\n";
                                }
                        break;
 
                case 2:         // details about not-passed tests
 
-                               foreach ($results as $result) {
+                               foreach ($results as $name=>$s) {
+                                       
                                        
-                                       $s = $result->getStatus();
-                                       $name = $s->__toString();
+                                       $status = $s->__toString();
                                        
-                                       if ($name !== 'pass') {
+                                       if ($status !== 'pass') {
                                                print "\n";
                                        }
                                        
-                                       print 
strtoupper($name)."\t".$result->getName()."\n";
+                                       print strtoupper($s)."\t".$name."\n";
 
-                                if ($name !== 'pass') {
-                                       print 
"DESC:\t".$result->getTitle()."\n";
-                                       
+                                if ($s !== 'pass') {
+                                                                               
                                        $msg = $s->getMessage($name);
                                        if (!is_null($msg)) {
                                                print "MSG:\t".$msg."\n";
@@ -260,17 +260,16 @@ abstract class rtTestOutputWriter
                        break;
 
                case 3:         // all available details
-
-                               foreach ($results as $result) {
+                  
+                               foreach ($results as $name=>$s) {
+                                       
+                                       $status = $s->__toString();
                                        
-                                       $s = $result->getStatus();
-                                       $name = $s->__toString();
-
                                        print "\n";
-                                       print 
strtoupper($name)."\t".$result->getName()."\n";
-                               print "DESC:\t".$result->getTitle()."\n";
-                                       
-                               $msg = $s->getMessage($name);
+                                       
+                                       print 
strtoupper($status)."\t".$name."\n";
+                               
+                               $msg = $s->getMessage($status);
 
                                if (!is_null($msg)) {
                                        print "MSG:\t".$msg."\n";
@@ -282,7 +281,7 @@ abstract class rtTestOutputWriter
 
                                        print 
"MEM:\t".round(memory_get_usage()/1024, 2)." kB\n";
                                        
-                                       $files = $result->getSavedFileNames();
+                                       $files = $s->getSavedFileNames();
                                        
                                        if (sizeof($files) > 0) {
                                                
diff --git a/src/testcase/rtTestResults.php b/src/testcase/rtTestResults.php
index b8f0e8e..bd9de2b 100644
--- a/src/testcase/rtTestResults.php
+++ b/src/testcase/rtTestResults.php
@@ -21,7 +21,6 @@ class rtTestResults
 {
     protected $testStatus;
     protected $testName = '';
-    protected $savedFileNames = array();
     protected $title = '';
     protected $time = 0;
     protected $redirectedTest;
@@ -35,11 +34,8 @@ class rtTestResults
     {
         if ($testCase != null) {
             $this->title = $testCase->getSection('TEST')->getHeader();
-            $this->testStatus = $testCase->getStatus();
+            $this->testStatus = $testCase->getStatus(); //is an object
             $this->testName = $testCase->getName();
-            if($testStatus == 'redirected') {
-               $this->redirectedTest = $testCase;
-            }
         } else {
             $this->testStatus = $testStatus;
             $this->testName = $testStatus->getTestName();
@@ -63,7 +59,7 @@ class rtTestResults
         
         if(file_exists($this->testName . '.mem')) {
             if(filesize($this->testName . '.mem') > 0) {
-                $this->savedFileNames['mem'] = $this->testName. ".mem";
+                $this->testStatus->setSavedFileName('mem', $this->testName. 
".mem");
             } else {
                 @unlink($this->testName . '.mem');
             }  
@@ -85,19 +81,19 @@ class rtTestResults
         if (!$runConfiguration->hasCommandLineOption('keep-all') && 
!$runConfiguration->hasCommandLineOption('keep-php')) {
             $testCase->getFileSection()->deleteFile();
         } else {
-            $this->savedFileNames['php'] = $this->testName. ".php";
+            $this->testStatus->setSavedFileName('php', $this->testName. 
".php");
         }
 
         if ($runConfiguration->hasCommandLineOption('keep-all') || 
$runConfiguration->hasCommandLineOption('keep-out')) {
             $outputFileName = $this->testName.".out";
             file_put_contents($outputFileName, $testCase->getOutput());
-            $this->savedFileNames['out'] = $outputFileName;
+            $this->testStatus->setSavedFileName('out', $outputFileName);
         }
 
         if ($runConfiguration->hasCommandLineOption('keep-all') || 
$runConfiguration->hasCommandLineOption('keep-exp')) {
             $expectedFileName = $this->testName.".exp";
             file_put_contents($expectedFileName, implode(b"\n", 
$testCase->getExpectSection()->getContents()));
-            $this->savedFileNames['exp'] = $expectedFileName;
+            $this->testStatus->setSavedFileName('exp', $expectedFileName);
         }
 
         if ($testCase->hasSection('XFAIL')) {
@@ -109,7 +105,7 @@ class rtTestResults
             if (!$runConfiguration->hasCommandLineOption('keep-all') && 
!$runConfiguration->hasCommandLineOption('keep-clean')) {
                 $testCase->getSection('CLEAN')->deleteFile();
             } else {
-                $this->savedFileNames['clean'] = $this->testName. ".clean.php";
+               $this->testStatus->setSavedFileName('claen', $this->testName. 
".clean.php");
             }
         }
 
@@ -118,7 +114,7 @@ class rtTestResults
         }
         
         if($testCase->getStatus()->getValue('leak') == true) {
-            $this->savedFileNames['mem'] = 
$testCase->getSection('FILE')->getMemFileName();
+            $this->testStatus->setSavedFileName('mem', 
$testCase->getSection('FILE')->getMemFileName());
         }
         
     }
@@ -136,9 +132,9 @@ class rtTestResults
         file_put_contents($outputFileName, $testCase->getOutput());
         file_put_contents($expectedFileName, implode(b"\n", 
$testCase->getExpectSection()->getContents()));
 
-        $this->savedFileNames['out'] = $outputFileName;
-        $this->savedFileNames['exp'] = $expectedFileName;
-        $this->savedFileNames['diff'] = $differenceFileName;
+        $this->testStatus->setSavedFileName('out', $outputFileName);
+        $this->testStatus->setSavedFileName('exp', $expectedFileName);
+        $this->testStatus->setSavedFileName('diff', $differenceFileName);
          
         if ($testCase->hasSection('XFAIL')) {
             $this->testStatus->setTrue('xfail');
@@ -148,22 +144,22 @@ class rtTestResults
 
         //Note: if there are clean and skipif files they will not be deleted 
if the test fails
         if ($testCase->hasSection('CLEAN')) {
-            $this->savedFileNames['clean'] = $this->testName. '.clean.php';
+               $this->testStatus->setSavedFileName('clean', $this->testName. 
'.clean.php' );
         }
 
         if ($testCase->hasSection('SKIPIF')) {
-            $this->savedFileNames['skipif'] = $this->testName. '.skipif.php';
+               $this->testStatus->setSavedFileName('skipif', $this->testName. 
'.skipif.php' );
         }
         
         if($testCase->getStatus()->getValue('leak') == true) {
-            $this->savedFileNames['mem'] = 
$testCase->getSection('FILE')->getMemFileName();
+               $this->testStatus->setSavedFileName('mem', 
$testCase->getSection('FILE')->getMemFileName());
         }
     }
 
     protected function onSkip(rtPhpTest $testCase, rtRuntestsConfiguration 
$runConfiguration)
     {
         if ($runConfiguration->hasCommandLineOption('keep-all') || 
$runConfiguration->hasCommandLineOption('keep-skip')) {
-            $this->savedFileNames['skipif'] = $this->testName. '.skipif.php';
+               $this->testStatus->setSavedFileName('skipif', $this->testName. 
'.skipif.php' );
         } else if($testCase->hasSection('SKIPIF')) {
             $testCase->getSection('SKIPIF')->deleteFile();
         }
@@ -176,10 +172,6 @@ class rtTestResults
         return $this->testStatus;
     }
 
-    public function getSavedFileNames()
-    {
-        return $this->savedFileNames;
-    }
 
     public function getName()
     {
diff --git a/src/testcase/rtTestStatus.php b/src/testcase/rtTestStatus.php
index 0a4504b..c881376 100644
--- a/src/testcase/rtTestStatus.php
+++ b/src/testcase/rtTestStatus.php
@@ -31,6 +31,7 @@ class rtTestStatus {
                                 'leak',
                                                        'redirected',
     );
+    protected $savedFileNames = array();
 
     public function __construct($testName)
     {
@@ -76,6 +77,15 @@ class rtTestStatus {
         return $this->testName;
     }
     
+       public function getSavedFileNames()
+    {
+        return $this->savedFileNames;
+    }
+       public function setSavedFileName($type, $fileName)
+    {
+        $this->savedFileNames[$type] = $fileName;
+    }
+    
     public function setExecutedPhpCommand($cmd)
     {
        $this->executedPhpCommand = $cmd;
diff --git a/src/testgroup/rtPhpTestGroup.php b/src/testgroup/rtPhpTestGroup.php
index b49c0b6..f6e8ff5 100644
--- a/src/testgroup/rtPhpTestGroup.php
+++ b/src/testgroup/rtPhpTestGroup.php
@@ -19,6 +19,7 @@ class rtPhpTestGroup extends rtTask implements rtTaskInterface
     protected $result = array();
     protected $runConfiguration;
     protected $groupConfiguration;
+    protected $redirectedTestCases = array();
 
     public function __construct(rtRuntestsConfiguration $runConfiguration, 
$directory, $groupConfiguration)
     {
@@ -27,6 +28,12 @@ class rtPhpTestGroup extends rtTask implements 
rtTaskInterface
         $this->groupConfiguration = $groupConfiguration;
         $this->init();
     }
+    
+    public function __destruct() {
+       unset ($this->testCases);
+       
+    }
+    
 
     public function init()
     {     
@@ -43,6 +50,7 @@ class rtPhpTestGroup extends rtTask implements rtTaskInterface
         $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
 
@@ -71,18 +79,22 @@ class rtPhpTestGroup extends rtTask implements 
rtTaskInterface
                        if($redirectedTest->getStatus()->getValue('skip')) {
                                $testStatus->setTrue('skip');
                                $testStatus->setMessage('skip', 
$testFile->getExitMessage(). ' and the skip condition has failed');
+                               $this->result[$testFile->getTestName()] = 
$testStatus;
                        } else {
                                $testStatus->setTrue('redirected');
                                $testStatus->setMessage('redirected', 
$testFile->getExitMessage());
+                               $this->result[$testFile->getTestName()] = 
$testStatus;
+                               $this->redirectedTestCases[] = $redirectedTest;
                        }
-                       $this->result[] = new rtTestResults($redirectedTest, 
$testStatus);
+                       
                }
                
             }else {
                 $testStatus->setTrue('bork');
                 $testStatus->setMessage('bork', $testFile->getExitMessage());
-                $this->result[] = new rtTestResults(null, $testStatus);
+                $this->result[$testFile->getTestName()] = $testStatus;
             }
+            //echo "\n" .memory_get_usage() . ", setup complete". 
$testFileName . "\n";
         }
     }
 
@@ -92,15 +104,27 @@ class rtPhpTestGroup extends rtTask implements 
rtTaskInterface
         if (count($this->testCases) == 0) {
             return;
         }
-       
-        foreach ($this->testCases as $testCase) {
+        //$s1 = memory_get_usage();
+        
+        //foreach ($this->testCases as $testCase) {
+        for($i=0; $i<count($this->testCases); $i++) {
+        
+               $testCase = $this->testCases[$i];
 
             $testCase->executeTest($this->runConfiguration);
+            
+          
              
             $testResult = new rtTestResults($testCase);
             $testResult->processResults($testCase, $this->runConfiguration);
-            $this->result[] = $testResult;
+            $this->result[$testCase->getName()] = $testResult->getStatus();
+            //unset($testResult); Makes no diffetence
+            //echo "\n" .memory_get_usage() . ", run end";
         }
+        
+        //$s2 = memory_get_usage();
+        //unset($this->testCases);
+        //echo "\n" .$s1. ", " .$s2. ", " .memory_get_usage() . ", after 
freeing test array\n"; //Shows memory creeping up
     }
 
     public function writeGroup($outType, $cid=null)
@@ -117,6 +141,10 @@ class rtPhpTestGroup extends rtTask implements 
rtTaskInterface
     public function getResults() {
        return $this->result;
     }
-
+    
+    public function getRedirectedTestCases() {
+       return $this->redirectedTestCases;
+    }
+    
 }
 ?>
diff --git a/src/testrun/rtPhpTestRun.php b/src/testrun/rtPhpTestRun.php
index 2850d33..f2cc34e 100644
--- a/src/testrun/rtPhpTestRun.php
+++ b/src/testrun/rtPhpTestRun.php
@@ -32,6 +32,7 @@ class rtPhpTestRun
 
        public function run()
        {
+
                //Set SSH variables
 
                // check the operation-system (win/unix)
@@ -87,13 +88,7 @@ class rtPhpTestRun
                                
$this->run_tests($this->runConfiguration->getSetting('TestFiles'));
                        }
                }
-               
-               /*
-                * At this stage we have run all groups or tests in the initial 
input. Now we check if any of those have 
-                * redirected test cases and if so, run those one group at a 
time.
-                * It might be possible to run these in parallel too?
-                */
-               $this->buildRedirectsList($this->resultList);
+
            if(count($this->redirectedTestCases) > 0) {
                $this->doRedirectedRuns();              
            }
@@ -101,6 +96,7 @@ class rtPhpTestRun
            if(($this->numberOfSerialGroups != 0) || 
($this->numberOfParallelGroups != 0))      {
                $this->createRunOutput();
            }
+           
        }
        
        public function doGroupRuns() {
@@ -117,7 +113,7 @@ class rtPhpTestRun
                        } else {
                                
                                //check to see if this is set to be a parallel 
run, if not, run the subdirectory groups in sequence.
-                               if($this->requestedProcessorCount() <= 1) {
+                               if($this->requestedProcessorCount() < 1) {
                                        
$this->run_serial_groups($subDirectories, $groupConfigurations);
                                        $this->numberOfSerialGroups = 
count($subDirectories);
                                } else {
@@ -181,11 +177,42 @@ class rtPhpTestRun
        
        public function run_serial_groups($testDirectories, 
$groupConfigurations) {
                
-               foreach($testDirectories as $subDirectory) {    
+               $count = 0;
+       
+               
+               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();
+
+                       
                        
rtTestOutputWriter::flushResult($testGroup->getResults(), $this->reportStatus); 
                
                $this->resultList[] = $testGroup->getResults();
+               
+               // Memory usage debugging
+               //$midm2 = memory_get_usage();
+               
+               $redirects = $testGroup->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";
                                                
                }               
        }
@@ -201,7 +228,6 @@ class rtPhpTestRun
                                exit();
                        }
                        
-                       $allResults = array();
                        
                        //Read the test file
                        $testFile = new rtPhpTestFile();
@@ -219,6 +245,7 @@ class rtPhpTestRun
 
                                $results = new rtTestResults($testCase);
                                $results->processResults($testCase, 
$this->runConfiguration);
+                               $summaryResults = 
array($testFile->getTestName() => $results->getStatus());
 
                        } elseif (in_array("REDIRECTTEST", 
$testFile->getSectionHeadings())) {
                                 
@@ -229,13 +256,15 @@ class rtPhpTestRun
                                 
                                $testStatus->setTrue('redirected');
                                $testStatus->setMessage('redirected', 
$testFile->getExitMessage());
-                               $results = new rtTestResults(null, $testStatus);
+                               $summaryResults = 
array($testFile->getTestName() => $testStatus);
+                               
                        } else {
                                $testStatus->setTrue('bork');
                                $testStatus->setMessage('bork', 
$testFile->getExitMessage());
-                               $results = new rtTestResults(null, $testStatus);
+                               $summaryResults = 
array($testFile->getTestName() => $testStatus);
                        }
-                       rtTestOutputWriter::flushResult(array($results), 3);
+           
+                       rtTestOutputWriter::flushResult($summaryResults, 3);
                        
                }                                
        }
@@ -321,5 +350,16 @@ class rtPhpTestRun
                }
        }
        
+       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;
+       }
+       
 }
 ?>
diff --git a/tests/rtPhpTestGroupTest.php b/tests/rtPhpTestGroupTest.php
index 0a02131..51e2527 100644
--- a/tests/rtPhpTestGroupTest.php
+++ b/tests/rtPhpTestGroupTest.php
@@ -46,14 +46,10 @@ class rtPHpTestGroupTest extends PHPUnit_Framework_TestCase
        
        
        
-       $inValidTests = $phpTestGroup->getResult();
+       $redirects = $phpTestGroup->getRedirectedTestCases();
        
-        foreach($inValidTests as $testResult) {
-               if($testResult->getStatus() == 'redirected') {
-                       //If the status has been set to redirected it should 
have a valid REDIRECTTEST section
-                       $testCase = $testResult->getRedirectedTestCase();
-                       
$this->assertTrue($testCase->hasSection('REDIRECTTEST'));
-               }               
+        foreach($redirects as $testCase) {     
+               $this->assertTrue($testCase->hasSection('REDIRECTTEST'));       
         }   
     }
-- 
PHP Quality Assurance Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to