Show
Ignore:
Timestamp:
05/15/2007 08:54:57 PM (20 months ago)
Author:
wei
Message:

update phing simpletest task

Location:
trunk/buildscripts/phing
Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php

    r1186 r1953  
    2222require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php'; 
    2323require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php'; 
    24 require_once 'phing/tasks/ext/phpunit2/FormatterElement.php'; 
     24require_once 'phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php'; 
    2525 
    2626/** 
     
    3333 * @since 2.2.0 
    3434 */ 
    35 class SimpleTestFormatterElement extends FormatterElement 
     35class SimpleTestFormatterElement 
    3636{ 
     37        protected $formatter = NULL; 
     38 
     39        protected $type = ""; 
     40 
     41        protected $useFile = true; 
     42 
     43        protected $toDir = "."; 
     44 
     45        protected $outfile = ""; 
     46 
    3747        function setType($type) 
    3848        { 
     
    4151                if ($this->type == "xml") 
    4252                { 
    43                         $destFile = new PhingFile($this->toDir, 'testsuites.xml'); 
    44                         //$this->formatter = new SimpleTestXmlResultFormatter(); 
     53                        //$destFile = new PhingFile($this->toDir, 'testsuites.xml'); 
     54                        $this->formatter = new SimpleTestXmlResultFormatter(); 
    4555                } 
    4656                else 
     
    5969                } 
    6070        } 
     71 
     72        function setClassName($className) 
     73        { 
     74                $classNameNoDot = Phing::import($className); 
     75 
     76                $this->formatter = new $classNameNoDot(); 
     77        } 
     78 
     79        function setUseFile($useFile) 
     80        { 
     81                $this->useFile = $useFile; 
     82        } 
     83 
     84        function getUseFile() 
     85        { 
     86                return $this->useFile; 
     87        } 
     88 
     89        function setToDir($toDir) 
     90        { 
     91                $this->toDir = $toDir; 
     92        } 
     93 
     94        function getToDir() 
     95        { 
     96                return $this->toDir; 
     97        } 
     98 
     99        function setOutfile($outfile) 
     100        { 
     101                $this->outfile = $outfile; 
     102        } 
     103 
     104        function getOutfile() 
     105        { 
     106                if ($this->outfile) 
     107                { 
     108                        return $this->outfile; 
     109                } 
     110                else 
     111                { 
     112                        return $this->formatter->getPreferredOutfile() . $this->getExtension(); 
     113                } 
     114        } 
     115 
     116        function getExtension() 
     117        { 
     118                return $this->formatter->getExtension(); 
     119        } 
     120 
     121        function getFormatter() 
     122        { 
     123                return $this->formatter; 
     124        } 
    61125} 
    62126?> 
  • trunk/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php

    r1186 r1953  
    3333{ 
    3434        private $inner = ""; 
    35          
     35 
    3636        function getExtension() 
    3737        { 
    3838                return ".txt"; 
    3939        } 
    40          
     40 
    4141        function getPreferredOutfile() 
    4242        { 
     
    4747        { 
    4848                parent::paintCaseStart($test_name); 
    49                  
     49 
    5050                $this->inner = ""; 
    5151        } 
    52          
     52 
    5353        function paintCaseEnd($test_name) 
    5454        { 
    5555                parent::paintCaseEnd($test_name); 
    56                  
     56 
    5757                /* Only count suites where more than one test was run */ 
    5858                if ($this->getRunCount()) 
    5959                { 
    60                         $sb.= "Testsuite: $test_name\n"; 
     60                        $sb = "Testsuite: $test_name\n"; 
    6161                        $sb.= "Tests run: " . $this->getRunCount(); 
    6262                        $sb.= ", Failures: " . $this->getFailureCount(); 
     
    7676        { 
    7777                parent::paintError($message); 
    78                  
     78 
    7979                $this->formatError("ERROR", $message); 
    8080        } 
     
    8383        { 
    8484                parent::paintFail($message); 
    85                  
     85 
    8686                $this->formatError("FAILED", $message); 
    8787        } 
     
    9090        { 
    9191                $this->inner.= $this->getTestName() . " " . $type . "\n"; 
    92                 $this->inner.= $message . "\n";  
     92                $this->inner.= $message . "\n"; 
    9393        } 
    9494} 
  • trunk/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php

    r1186 r1953  
    2020 */ 
    2121 
    22 require_once 'simpletest/scorer.php'; 
     22//require_once 'simpletest/scorer.php'; 
    2323 
    2424require_once 'phing/system/io/Writer.php'; 
     
    3535{ 
    3636        protected $out = NULL; 
    37          
     37 
    3838        protected $project = NULL; 
    39          
     39 
    4040        private $timer = NULL; 
    4141 
    4242        private $runCount = 0; 
    43          
     43 
    4444        private $failureCount = 0; 
    45          
    46         private $errorCount = 0;         
     45 
     46        private $errorCount = 0; 
    4747 
    4848        private $currentTest = ""; 
    49          
     49 
    5050        /** 
    5151         * Sets the writer the formatter is supposed to write its results to. 
     
    5353        function setOutput(Writer $out) 
    5454        { 
    55                 $this->out = $out;       
     55                $this->out = $out; 
    5656        } 
    5757 
     
    7575                $this->project = $project; 
    7676        } 
    77          
     77 
    7878        function getPreferredOutfile() 
    7979        { 
    8080                return ""; 
    8181        } 
    82          
     82 
    8383        function paintMethodStart($test_name) 
    8484        { 
    8585                parent::paintMethodStart($test_name); 
    86                  
     86 
    8787                $this->currentTest = $test_name; 
    8888        } 
    89          
     89 
    9090        function paintMethodEnd($test_name) 
    9191        { 
    9292                parent::paintMethodEnd($test_name); 
    93                  
     93 
    9494                $this->runCount++; 
    9595        } 
    96          
     96 
    9797        function paintCaseStart($test_name) 
    9898        { 
    9999                parent::paintCaseStart($test_name); 
    100                  
     100 
    101101                $this->runCount = 0; 
    102102                $this->failureCount = 0; 
    103103                $this->errorCount = 0; 
    104                  
     104 
    105105                $this->timer = new Timer(); 
    106106                $this->timer->start(); 
    107107        } 
    108                  
     108 
    109109        function paintCaseEnd($test_name) 
    110110        { 
    111111                parent::paintCaseEnd($test_name); 
    112                  
     112 
    113113                $this->timer->stop(); 
    114114        } 
     
    117117        { 
    118118                parent::paintError($message); 
    119                  
     119 
    120120                $this->errorCount++; 
    121121        } 
     
    124124        { 
    125125                parent::paintFail($message); 
    126                  
     126 
    127127                $this->failureCount++; 
    128128        } 
     
    132132                return $this->runCount; 
    133133        } 
    134          
     134 
    135135        function getFailureCount() 
    136136        { 
    137137                return $this->failureCount; 
    138138        } 
    139          
     139 
    140140        function getErrorCount() 
    141141        { 
    142142                return $this->errorCount; 
    143143        } 
    144          
     144 
    145145        function getTestName() 
    146146        { 
    147147                return $this->currentTest; 
    148148        } 
    149          
     149 
    150150        function getElapsedTime() 
    151151        { 
  • trunk/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php

    r1186 r1953  
    3535        { 
    3636                parent::paintCaseEnd($test_name); 
    37                  
     37 
    3838                /* Only count suites where more than one test was run */ 
    3939                if ($this->getRunCount()) 
    4040                { 
    41                         $sb.= "Tests run: " . $this->getRunCount(); 
     41                        $sb= "Tests run: " . $this->getRunCount(); 
    4242                        $sb.= ", Failures: " . $this->getFailureCount(); 
    4343                        $sb.= ", Errors: " . $this->getErrorCount(); 
  • trunk/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php

    r1186 r1953  
    4242        private $printsummary = false; 
    4343        private $testfailed = false; 
     44        private $filesets=array(); 
    4445 
    4546        /** 
     
    5051         */ 
    5152        function init() { 
    52                 @include_once 'simpletest/scorer.php'; 
    53                  
     53 
    5454                if (!class_exists('SimpleReporter')) { 
    5555                        throw new BuildException("SimpleTestTask depends on SimpleTest package being installed.", $this->getLocation()); 
    5656                } 
    57                  
    58                 require_once 'simpletest/reporter.php'; 
    59                 require_once 'simpletest/xml.php'; 
    60                 require_once 'simpletest/test_case.php'; 
    6157                require_once 'phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php'; 
    6258                require_once 'phing/tasks/ext/simpletest/SimpleTestFormatterElement.php'; 
    6359        } 
    64          
     60 
    6561        function setFailureproperty($value) 
    6662        { 
    6763                $this->failureproperty = $value; 
    6864        } 
    69          
     65 
    7066        function setErrorproperty($value) 
    7167        { 
    7268                $this->errorproperty = $value; 
    7369        } 
    74          
     70 
    7571        function setHaltonerror($value) 
    7672        { 
     
    8783                $this->printsummary = $printsummary; 
    8884        } 
    89          
     85 
    9086        /** 
    9187         * Add a new formatter to all tests of this task. 
     
    145141        { 
    146142                $group = new GroupTest(); 
    147                  
     143 
    148144                $filenames = $this->getFilenames(); 
    149                  
     145 
    150146                foreach ($filenames as $testfile) 
    151147                { 
    152148                        $group->addTestFile($testfile); 
    153149                } 
    154                  
     150 
    155151                if ($this->printsummary) 
    156152                { 
     
    160156                        $this->formatters[] = $fe; 
    161157                } 
    162                  
     158 
    163159                foreach ($this->formatters as $fe) 
    164160                { 
     
    169165                        { 
    170166                                $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile()); 
    171                                  
     167 
    172168                                $writer = new FileWriter($destFile->getAbsolutePath()); 
    173169 
     
    179175                        } 
    180176                } 
    181                  
     177 
    182178                $this->execute($group); 
    183                  
     179 
    184180                if ($this->testfailed) 
    185181                { 
     
    187183                } 
    188184        } 
    189          
     185 
    190186        private function execute($suite) 
    191187        { 
     
    193189                $reporter = new MultipleReporter(); 
    194190                $reporter->attachReporter($counter); 
    195                  
     191 
    196192                foreach ($this->formatters as $fe) 
    197193                { 
     
    199195 
    200196                        $reporter->attachReporter($formatter); 
    201                 }                
    202                  
     197                } 
     198 
    203199                $suite->run($reporter); 
    204                  
     200 
    205201                $retcode = $counter->getRetCode(); 
    206                  
     202 
    207203                if ($retcode == SimpleTestCountResultFormatter::ERRORS) 
    208204                { 
     
    211207                                $this->project->setNewProperty($this->errorproperty, true); 
    212208                        } 
    213                          
     209 
    214210                        if ($this->haltonerror) 
    215211                        { 
     
    223219                                $this->project->setNewProperty($this->failureproperty, true); 
    224220                        } 
    225                          
     221 
    226222                        if ($this->haltonfailure) 
    227223                        {