g2              Mon Jun 29 22:00:13 2009 UTC

  Modified files:              
    /phpruntests/src/testcase/output    rtTestOutputWriterXML.php 
    /phpruntests/src/testgroup  rtPhpTestGroup.php 
    /phpruntests/src/taskScheduler      rtTaskSchedulerFile.php 
                                        rtTaskTestGroup.php 
  Log:
  phpruntests - update taskScheduler - fixed out-of-memory-bug while running 
large tests
  
http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/output/rtTestOutputWriterXML.php?r1=1.4&r2=1.5&diff_format=u
Index: phpruntests/src/testcase/output/rtTestOutputWriterXML.php
diff -u phpruntests/src/testcase/output/rtTestOutputWriterXML.php:1.4 
phpruntests/src/testcase/output/rtTestOutputWriterXML.php:1.5
--- phpruntests/src/testcase/output/rtTestOutputWriterXML.php:1.4       Mon Jun 
29 01:34:54 2009
+++ phpruntests/src/testcase/output/rtTestOutputWriterXML.php   Mon Jun 29 
22:00:12 2009
@@ -52,10 +52,8 @@
 
 
     /**
-     *
-     *
+        *
      * @param array of rtTestResults
-     *
      */
     public function init (array $testResults)
     {
@@ -103,5 +101,6 @@
        
        return null;
     }
+    
 }
-?>
+?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/phpruntests/src/testgroup/rtPhpTestGroup.php?r1=1.11&r2=1.12&diff_format=u
Index: phpruntests/src/testgroup/rtPhpTestGroup.php
diff -u phpruntests/src/testgroup/rtPhpTestGroup.php:1.11 
phpruntests/src/testgroup/rtPhpTestGroup.php:1.12
--- phpruntests/src/testgroup/rtPhpTestGroup.php:1.11   Mon Jun 29 01:34:54 2009
+++ phpruntests/src/testgroup/rtPhpTestGroup.php        Mon Jun 29 22:00:13 2009
@@ -75,5 +75,12 @@
         $testOutputWriter = rtTestOutputWriter::getInstance($this->results, 
$outType);
         $testOutputWriter->write($this->testDirectory, $cid);
     }
+    
+    
+    public function getResults()
+    {
+       return $this->results;
+    }
+
 }
 ?>
http://cvs.php.net/viewvc.cgi/phpruntests/src/taskScheduler/rtTaskSchedulerFile.php?r1=1.3&r2=1.4&diff_format=u
Index: phpruntests/src/taskScheduler/rtTaskSchedulerFile.php
diff -u phpruntests/src/taskScheduler/rtTaskSchedulerFile.php:1.3 
phpruntests/src/taskScheduler/rtTaskSchedulerFile.php:1.4
--- phpruntests/src/taskScheduler/rtTaskSchedulerFile.php:1.3   Mon Jun 29 
01:34:54 2009
+++ phpruntests/src/taskScheduler/rtTaskSchedulerFile.php       Mon Jun 29 
22:00:13 2009
@@ -17,11 +17,9 @@
 {
        const TMP_FILE = 'taskFile';
        
-       private $inputQueue = NULL;             // the input-queue (only used 
by the sender)
        private $pidStore = array();    // stores the pids of all 
child-processes
        private $groupTasks = false;    // are the tasks stored in groups?
-       
-       private $tmpTaskList = array();
+
        
        /**
         * the constructor
@@ -59,8 +57,6 @@
                $this->taskList = $taskList;
        }
 
-       
-       
        /**
         * sets the number of child-processes.
         * in the case of using a multidimensional task-list this parameter is
@@ -76,7 +72,6 @@
                }
        }
 
-
        
        /**
         * starts the sender, the receiver and forks the defined
@@ -98,8 +93,8 @@
                        $this->processCount = sizeof($this->taskList);
                }
 
+               // distribute the task to the children
                $this->createTaskFiles();
-               
 
                // fork the child-processes
                for ($i=0; $i<$this->processCount; $i++) {
@@ -126,7 +121,7 @@
                        pcntl_waitpid($this->pidStore[$i], $status);
                }
                
-               // ensure that the tmp-files are completly written
+               // ensure that the tmp-files are completely written
                sleep(1);
                
                // collecting the results
@@ -137,8 +132,7 @@
 
                return;
        }
-       
-       
+
        
        /**
         * creates a temporary file for each child which stores the allocated 
@@ -180,8 +174,9 @@
        }
 
        
-       
        /**
+        * 
+        * 
         * @return void
         */
        private function receiver()
@@ -202,7 +197,7 @@
                                }
 
                                $index = $task->getIndex();
-                               $task->finish($cid);
+                               $task->evaluate($cid);
                                
                                if ($this->groupTasks == true) { 
                                        
@@ -219,10 +214,12 @@
                
                return;         
        }
-       
 
        
        /**
+        * executes the assigned tasks and stores the serialized task-object in
+        * the task-file. 
+        * 
         * @param  int  $cid    the child-id
         * @return void
         */
@@ -231,24 +228,26 @@
                $indexList = file_get_contents(self::TMP_FILE.$cid);
                $indexList = explode(';', $indexList);
                array_pop($indexList);
-               
-               $response = '';
+
+               file_put_contents(self::TMP_FILE.$cid, '');
 
                foreach ($indexList as $index) {
 
                        if ($this->groupTasks == true) { 
-                               $task = $this->taskList[$cid][$index]; 
+                               $task = $this->taskList[$cid][$index];
                        } else {
                                $task = $this->taskList[$index];
                        }
 
                        $task->run();
                        $task->setIndex($index);
-
-                       $response .= serialize($task)."[END-TEST-OBJECT]";
+                       
+                       print "$cid - ".$task->getDir()." - 
".round(memory_get_usage()/1024, 2)."\n";
+                       flush();
+                       
+                       $response = serialize($task)."[END-TEST-OBJECT]";
+                       file_put_contents(self::TMP_FILE.$cid, $response, 
FILE_APPEND);
                }
-               
-               file_put_contents(self::TMP_FILE.$cid, $response);
 
                exit(0);
        }
http://cvs.php.net/viewvc.cgi/phpruntests/src/taskScheduler/rtTaskTestGroup.php?r1=1.4&r2=1.5&diff_format=u
Index: phpruntests/src/taskScheduler/rtTaskTestGroup.php
diff -u phpruntests/src/taskScheduler/rtTaskTestGroup.php:1.4 
phpruntests/src/taskScheduler/rtTaskTestGroup.php:1.5
--- phpruntests/src/taskScheduler/rtTaskTestGroup.php:1.4       Mon Jun 29 
01:34:54 2009
+++ phpruntests/src/taskScheduler/rtTaskTestGroup.php   Mon Jun 29 22:00:13 2009
@@ -15,35 +15,58 @@
 {
        private $runConfiguration;
        private $subDirectory;
-       private $testGroup;
+       private $results;
+
        
        public function __construct($runConfiguration, $subDirectory)
        {
                $this->runConfiguration = $runConfiguration;
                $this->subDirectory = $subDirectory;
        }
-               
+       
+       
+       /**
+        * called by the child-process
+        * executes the the test-group
+        */
        public function run()
        {
-               $this->testGroup = new rtPhpTestGroup($this->runConfiguration, 
$this->subDirectory);
-               $this->testGroup->runGroup($this->runConfiguration);
-               
+               $testGroup = new rtPhpTestGroup($this->runConfiguration, 
$this->subDirectory);
+               $testGroup->runGroup($this->runConfiguration);
+        $this->results = $testGroup->getResults();
                return true;
        }
        
-       public function finish($cid=null) {
-
-               if (!is_null($cid)) {
-                       print "\n$cid - ".$this->subDirectory."\n";
-               }
-               
+       
+       /**
+        * called by the receiver (parent-process)
+        * writes the results to the OutputWriter
+        * 
+        * @param $cid  the child-id
+        */
+       public function evaluate($cid=null)
+       {
                $outType = 'list';
         if ($this->runConfiguration->hasCommandLineOption('o')) {              
        
                $outType = $this->runConfiguration->getCommandLineOption('o');
         } 
-               
-        $this->testGroup->writeGroup($outType, $cid);
+
+       $testOutputWriter = rtTestOutputWriter::getInstance($this->results, 
$outType);
+        $testOutputWriter->write($this->subDirectory, $cid);
        }
+       
+       
+       public function getDir()
+       {
+               return $this->subDirectory;
+       }
+       
+       
+    public function getResults()
+    {
+       return $this->results;
+    }
+    
 }
 
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to