Show
Ignore:
Timestamp:
04/28/06 14:49:47 (3 years ago)
Author:
mrook
Message:

Merge r23:r57 from trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/classes/phing/tasks/defaults.properties

    r58 r59  
    6060phpunit2report=phing.tasks.ext.phpunit2.PHPUnit2ReportTask 
    6161coverage-setup=phing.tasks.ext.coverage.CoverageSetupTask 
     62coverage-merger=phing.tasks.ext.coverage.CoverageMergerTask 
    6263coverage-report=phing.tasks.ext.coverage.CoverageReportTask 
    6364ioncubeencoder=phing.tasks.ext.ioncube.IoncubeEncoderTask 
    6465ioncubelicense=phing.tasks.ext.ioncube.IoncubeLicenseTask 
    6566simpletest=phing.tasks.ext.simpletest.SimpleTestTask 
     67phplint=phing.tasks.ext.PhpLintTask 
     68xmllint=phing.tasks.ext.XmlLintTask 
     69analyze=phing.tasks.ext.ZendCodeAnalyzerTask 
  • branches/2.2/classes/phing/tasks/ext/CapsuleTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    22 
    33/* 
    4  *  $Id: CapsuleTask.php,v 1.17 2005/05/26 13:10:52 mrook Exp
     4 *  $Id
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/CreoleSQLExecTask.php

    • Property svn:keywords set to author date id revision
    r45 r59  
    11<?php 
    22/* 
    3  *  $Id: CreoleSQLExecTask.php,v 1.21 2005/12/02 20:21:17 mrook Exp
     3 *  $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/CreoleTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    22 
    33/* 
    4  *  $Id: CreoleTask.php,v 1.13 2005/02/27 20:52:10 mrook Exp
     4 *  $Id
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/MailTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/* 
    3  *  $Id: MailTask.php,v 1.1 2005/02/03 10:07:56 mrook Exp
     3 *  $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/PackageAsPathTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    22 
    33/* 
    4  *  $Id: PackageAsPathTask.php,v 1.5 2003/12/24 12:38:40 hlellelid Exp
     4 *  $Id
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/PearPackageTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/* 
    3  *  $Id: PearPackageTask.php,v 1.9 2005/06/09 11:04:39 mrook Exp
     3 *  $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/PhpLintTask.php

    • Property svn:keywords set to author date id revision
  • branches/2.2/classes/phing/tasks/ext/SmartyTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    22 
    33/* 
    4  *  $Id: SmartyTask.php,v 1.13 2005/05/26 13:10:52 mrook Exp
     4 *  $Id
    55 * 
    66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3838 * @author    Jason van Zyl <jvanzyl@apache.org> (TexenTask) 
    3939 * @author    Robert Burrell Donkin <robertdonkin@mac.com> 
    40  * @version   $Id: SmartyTask.php,v 1.13 2005/05/26 13:10:52 mrook Exp
     40 * @version   $Id
    4141 * @package   phing.tasks.ext 
    4242 */ 
  • branches/2.2/classes/phing/tasks/ext/TarTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/* 
    3  *  $Id: TarTask.php,v 1.10 2005/05/26 13:10:52 mrook Exp
     3 *  $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/ZipTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/* 
    3  *  $Id: ZipTask.php,v 1.2 2005/05/26 13:10:52 mrook Exp
     3 *  $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  • branches/2.2/classes/phing/tasks/ext/coverage/CoverageMerger.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: CoverageMerger.php,v 1.1 2005/12/02 21:17:26 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2020 */ 
    2121 
    22 require_once 'PHPUnit2/Framework/Test.php'; 
     22require_once 'phing/system/util/Properties.php'; 
    2323 
    2424/** 
     
    2626 * 
    2727 * @author Michiel Rook <michiel@trendserver.nl> 
    28  * @version $Id: CoverageMerger.php,v 1.1 2005/12/02 21:17:26 mrook Exp
     28 * @version $Id
    2929 * @package phing.tasks.ext.coverage 
    3030 * @since 2.1.0 
  • branches/2.2/classes/phing/tasks/ext/coverage/CoverageReportTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: CoverageReportTask.php,v 1.11 2005/05/26 13:10:52 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3131 * 
    3232 * @author Michiel Rook <michiel@trendserver.nl> 
    33  * @version $Id: CoverageReportTask.php,v 1.11 2005/05/26 13:10:52 mrook Exp
     33 * @version $Id
    3434 * @package phing.tasks.ext.coverage 
    3535 * @since 2.1.0 
     
    188188                                $line = rtrim($line); 
    189189 
    190                                 $lines[$i] = utf8_encode(htmlspecialchars($line)); 
     190                                $lines[$i] = utf8_encode($line); 
    191191                        } 
    192192                         
     
    195195        } 
    196196 
    197         protected function transformSourceFile($basename, $filename, $coverageInformation, $classStartLine = 1) 
     197        protected function transformSourceFile($filename, $coverageInformation, $classStartLine = 1) 
    198198        { 
    199199                $sourceElement = $this->doc->createElement('sourcefile'); 
    200                 $sourceElement->setAttribute('name', $basename); 
     200                $sourceElement->setAttribute('name', basename($filename)); 
    201201 
    202202                $filelines = $this->highlightSourceFile($filename); 
     
    224224                return $sourceElement; 
    225225        } 
    226  
    227         protected function transformCoverageInformation($basename, $filename, $coverageInformation) 
    228         { 
    229                 $dotpath = strtr(dirname($basename), PhingFile::$separator, '.'); 
    230                 $classname = PHPUnit2Util::getClassFromFileName($basename); 
     226         
     227        protected function filterCovered($var) 
     228        { 
     229                return ($var >= 0); 
     230        } 
     231 
     232        protected function transformCoverageInformation($filename, $coverageInformation) 
     233        { 
     234                $classes = PHPUnit2Util::getDefinedClasses($filename, $this->classpath); 
    231235                 
    232                 Phing::import($dotpath . '.' . $classname, $this->classpath); 
    233  
    234                 try 
    235                 { 
    236                         $reflection = new ReflectionClass($classname); 
    237                 } 
    238                 catch (Exception $ex) 
    239                 { 
    240                         throw new BuildException($ex->getMessage()); 
    241                 } 
    242  
    243                 if ($reflection->isInterface()) 
    244                 { 
    245                         return; 
    246                 } 
    247  
    248                 $methods = $reflection->getMethods(); 
    249  
    250                 $classElement = $this->doc->createElement('class'); 
    251                 $classElement->setAttribute('name', $reflection->getName()); 
    252  
    253                 $this->addClassToPackage($reflection->getName(), $classElement); 
    254  
    255                 $methodscovered = 0; 
    256                 $methodcount = 0; 
    257  
    258                 reset($coverageInformation); 
    259  
    260                 foreach ($methods as $method) 
    261                 { 
    262                         // PHP5 reflection considers methods of a parent class to be part of a subclass, we don't 
    263                         if ($method->getDeclaringClass()->getName() != $reflection->getName()) 
     236                if (is_array($classes)) 
     237                { 
     238                        foreach ($classes as $classname) 
    264239                        { 
    265                                 continue; 
     240                                $reflection = new ReflectionClass($classname); 
     241                                 
     242                                $methods = $reflection->getMethods(); 
     243                                 
     244                                $classElement = $this->doc->createElement('class'); 
     245                                $classElement->setAttribute('name', $reflection->getName()); 
     246                                 
     247                                $this->addClassToPackage($reflection->getName(), $classElement); 
     248 
     249                                $classStartLine = $reflection->getStartLine(); 
     250                                 
     251                                $methodscovered = 0; 
     252                                $methodcount = 0; 
     253                                 
     254                                end($coverageInformation); 
     255                                unset($coverageInformation[key($coverageInformation)]); 
     256                                 
     257                                // Strange PHP5 reflection bug, classes without parent class or implemented interfaces seem to start one line off 
     258                                if ($reflection->getParentClass() == NULL && count($reflection->getInterfaces()) == 0) 
     259                                { 
     260                                        unset($coverageInformation[$classStartLine + 1]); 
     261                                } 
     262                                else 
     263                                { 
     264                                        unset($coverageInformation[$classStartLine]); 
     265                                } 
     266                                 
     267                                reset($coverageInformation);                             
     268                                 
     269                                foreach ($methods as $method) 
     270                                { 
     271                                        // PHP5 reflection considers methods of a parent class to be part of a subclass, we don't 
     272                                        if ($method->getDeclaringClass()->getName() != $reflection->getName()) 
     273                                        { 
     274                                                continue; 
     275                                        } 
     276 
     277                                        // small fix for XDEBUG_CC_UNUSED 
     278                                        if (isset($coverageInformation[$method->getStartLine()])) 
     279                                        { 
     280                                                unset($coverageInformation[$method->getStartLine()]); 
     281                                        } 
     282 
     283                                        if (isset($coverageInformation[$method->getEndLine()])) 
     284                                        { 
     285                                                unset($coverageInformation[$method->getEndLine()]); 
     286                                        } 
     287 
     288                                        if ($method->isAbstract()) 
     289                                        { 
     290                                                continue; 
     291                                        } 
     292 
     293                                        $linenr = key($coverageInformation); 
     294 
     295                                        while ($linenr < $method->getStartLine()) 
     296                                        { 
     297                                                next($coverageInformation); 
     298                                                $linenr = key($coverageInformation); 
     299                                        } 
     300 
     301                                        if (current($coverageInformation) > 0 && $method->getStartLine() <= $linenr && $linenr <= $method->getEndLine()) 
     302                                        { 
     303                                                $methodscovered++; 
     304                                        } 
     305 
     306                                        $methodcount++; 
     307                                } 
     308 
     309                                $statementcount = count($coverageInformation); 
     310                                $statementscovered = count(array_filter($coverageInformation, array($this, 'filterCovered'))); 
     311 
     312                                $classElement->appendChild($this->transformSourceFile($filename, $coverageInformation, $classStartLine)); 
     313 
     314                                $classElement->setAttribute('methodcount', $methodcount); 
     315                                $classElement->setAttribute('methodscovered', $methodscovered); 
     316                                $classElement->setAttribute('statementcount', $statementcount); 
     317                                $classElement->setAttribute('statementscovered', $statementscovered); 
     318                                $classElement->setAttribute('totalcount', $methodcount + $statementcount); 
     319                                $classElement->setAttribute('totalcovered', $methodscovered + $statementscovered); 
    266320                        } 
    267  
    268                         // small fix for XDEBUG_CC_UNUSED 
    269                         if (isset($coverageInformation[$method->getStartLine()])) 
    270                         { 
    271                                 unset($coverageInformation[$method->getStartLine()]); 
    272                         } 
    273  
    274                         if (isset($coverageInformation[$method->getEndLine()])) 
    275                         { 
    276                                 unset($coverageInformation[$method->getEndLine()]); 
    277                         } 
    278  
    279                         if ($method->isAbstract()) 
    280                         { 
    281                                 continue; 
    282                         } 
    283  
    284                         $linenr = key($coverageInformation); 
    285  
    286                         while ($linenr < $method->getStartLine() && current($coverageInformation) > 0) 
    287                         { 
    288                                 next($coverageInformation); 
    289                                 $linenr = key($coverageInformation); 
    290                         } 
    291  
    292                         if ($method->getStartLine() <= $linenr && $linenr <= $method->getEndLine()) 
    293                         { 
    294                                 $methodscovered++; 
    295                         } 
    296                                          
    297                         $methodcount++; 
    298                 } 
    299  
    300                 $classStartLine = $reflection->getStartLine(); 
    301  
    302                 // Strange PHP5 reflection bug, classes without parent class or implemented interfaces seem to start one line off 
    303                 if ($reflection->getParentClass() == NULL && count($reflection->getInterfaces()) == 0) 
    304                 { 
    305                         $classStartLine--; 
    306                 } 
    307  
    308                 $classElement->appendChild($this->transformSourceFile($basename, $filename, $coverageInformation, $classStartLine)); 
    309  
    310                 $classElement->setAttribute('methodcount', $methodcount); 
    311                 $classElement->setAttribute('methodscovered', $methodscovered); 
     321                } 
    312322        } 
    313323 
     
    319329                $totalmethodscovered = 0; 
    320330 
     331                $totalstatementcount = 0; 
     332                $totalstatementscovered = 0; 
     333 
    321334                foreach ($packages as $package) 
    322335                { 
    323336                        $methodcount = 0; 
    324337                        $methodscovered = 0; 
     338 
     339                        $statementcount = 0; 
     340                        $statementscovered = 0; 
    325341 
    326342                        $classes = $package->getElementsByTagName('class'); 
     
    330346                                $methodcount += $class->getAttribute('methodcount'); 
    331347                                $methodscovered += $class->getAttribute('methodscovered'); 
     348 
     349                                $statementcount += $class->getAttribute('statementcount'); 
     350                                $statementscovered += $class->getAttribute('statementscovered'); 
    332351                        } 
    333352 
     
    335354                        $package->setAttribute('methodscovered', $methodscovered); 
    336355 
     356                        $package->setAttribute('statementcount', $statementcount); 
     357                        $package->setAttribute('statementscovered', $statementscovered); 
     358 
     359                        $package->setAttribute('totalcount', $methodcount + $statementcount); 
     360                        $package->setAttribute('totalcovered', $methodscovered + $statementscovered); 
     361 
    337362                        $totalmethodcount += $methodcount; 
    338363                        $totalmethodscovered += $methodscovered; 
     364 
     365                        $totalstatementcount += $statementcount; 
     366                        $totalstatementscovered += $statementscovered; 
    339367                } 
    340368 
    341369                $this->doc->documentElement->setAttribute('methodcount', $totalmethodcount); 
    342370                $this->doc->documentElement->setAttribute('methodscovered', $totalmethodscovered); 
     371 
     372                $this->doc->documentElement->setAttribute('statementcount', $totalstatementcount); 
     373                $this->doc->documentElement->setAttribute('statementscovered', $totalstatementscovered); 
     374 
     375                $this->doc->documentElement->setAttribute('totalcount', $totalmethodcount + $totalstatementcount); 
     376                $this->doc->documentElement->setAttribute('totalcovered', $totalmethodscovered + $totalstatementscovered); 
    343377        } 
    344378 
    345379        function main() 
    346380        { 
     381                $this->log("Transforming coverage report"); 
     382                 
    347383                $database = new PhingFile($this->project->getProperty('coverage.database')); 
    348384                 
     
    354390                        $file = unserialize($props->getProperty($filename)); 
    355391 
    356                         $this->transformCoverageInformation($file['basename'], $file['fullname'], $file['coverage']); 
    357                 } 
    358  
     392                        $this->transformCoverageInformation($file['fullname'], $file['coverage']); 
     393                } 
     394                 
    359395                $this->calculateStatistics(); 
    360396 
    361397                $this->doc->save($this->outfile); 
    362398 
    363               foreach ($this->transformers as $transformer) 
    364               { 
     399              foreach ($this->transformers as $transformer) 
     400              { 
    365401                        $transformer->setXmlDocument($this->doc); 
    366402                        $transformer->transform(); 
  • branches/2.2/classes/phing/tasks/ext/coverage/CoverageReportTransformer.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: CoverageReportTransformer.php,v 1.8 2005/10/31 13:00:32 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    3030 * 
    3131 * @author Michiel Rook <michiel@trendserver.nl> 
    32  * @version $Id: CoverageReportTransformer.php,v 1.8 2005/10/31 13:00:32 mrook Exp
     32 * @version $Id
    3333 * @package phing.tasks.ext.coverage 
    3434 * @since 2.1.0 
  • branches/2.2/classes/phing/tasks/ext/coverage/CoverageSetupTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: CoverageSetupTask.php,v 1.9 2005/05/26 13:10:52 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2424require_once 'phing/system/io/Writer.php'; 
    2525require_once 'phing/system/util/Properties.php'; 
     26require_once 'phing/tasks/ext/coverage/CoverageMerger.php'; 
    2627 
    2728/** 
     
    2930 * 
    3031 * @author Michiel Rook <michiel@trendserver.nl> 
    31  * @version $Id: CoverageSetupTask.php,v 1.9 2005/05/26 13:10:52 mrook Exp
     32 * @version $Id
    3233 * @package phing.tasks.ext.coverage 
    3334 * @since 2.1.0 
     
    4041        /** the filename of the coverage database */ 
    4142        private $database = "coverage.db"; 
     43 
     44        /** the classpath to use (optional) */ 
     45        private $classpath = NULL; 
    4246 
    4347        /** 
     
    6165        } 
    6266 
     67        function setClasspath(Path $classpath) 
     68        { 
     69                if ($this->classpath === null) 
     70                { 
     71                        $this->classpath = $classpath; 
     72                } 
     73                else 
     74                { 
     75                        $this->classpath->append($classpath); 
     76                } 
     77        } 
     78 
     79        function createClasspath() 
     80        { 
     81                $this->classpath = new Path(); 
     82                return $this->classpath; 
     83        } 
     84         
    6385        /** 
    6486         * Iterate over all filesets and return the filename of all files 
     
    83105                                if (strstr($file, ".php")) 
    84106                                { 
    85                                         $fs = new PhingFile(basename($ds->getBaseDir()), $file); 
     107                                        $fs = new PhingFile(realpath($ds->getBaseDir()), $file); 
    86108                                         
    87                                         $files[] = array('key' => strtolower($fs->getAbsolutePath()), 'fullname' => $fs->getAbsolutePath(), 'basename' => $file); 
     109                                        $files[] = array('key' => strtolower($fs->getAbsolutePath()), 'fullname' => $fs->getAbsolutePath()); 
    88110                                } 
    89111                        } 
     
    105127                $files = $this->getFilenames(); 
    106128 
     129                $this->log("Setting up coverage database for " . count($files) . " files"); 
     130 
    107131                $props = new Properties(); 
    108132 
    109133                foreach ($files as $file) 
    110134                { 
    111                         $basename = $file['basename']; 
    112135                        $fullname = $file['fullname']; 
    113136                        $filename = $file['key']; 
    114137                         
    115                         $props->setProperty($filename, serialize(array('basename' => $basename, 'fullname' => $fullname, 'coverage' => array()))); 
     138                        $props->setProperty($filename, serialize(array('fullname' => $fullname, 'coverage' => array()))); 
    116139                } 
    117140 
     
    121144 
    122145                $this->project->setProperty('coverage.database', $dbfile->getAbsolutePath()); 
     146         
     147                foreach ($files as $file) 
     148                { 
     149                        $fullname = $file['fullname']; 
     150                         
     151                        xdebug_start_code_coverage(XDEBUG_CC_UNUSED); 
     152                         
     153                        Phing::__import($fullname, $this->classpath); 
     154                         
     155                        $coverage = xdebug_get_code_coverage(); 
     156                         
     157                        xdebug_stop_code_coverage(); 
     158                         
     159                        CoverageMerger::merge($this->project, array($coverage)); 
     160                } 
    123161        } 
    124162} 
  • branches/2.2/classes/phing/tasks/ext/ioncube/IoncubeComment.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: IoncubeComment.php,v 1.1 2006/01/30 10:32:35 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2424 * 
    2525 * @author Michiel Rook <michiel@trendserver.nl> 
    26  * @version $Id: IoncubeComment.php,v 1.1 2006/01/30 10:32:35 mrook Exp
     26 * @version $Id
    2727 * @package phing.tasks.ext.ioncube 
    2828 * @since 2.2.0 
  • branches/2.2/classes/phing/tasks/ext/ioncube/IoncubeEncoderTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: IoncubeEncoderTask.php,v 1.6 2006/02/03 10:39:23 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2727 * 
    2828 * @author Michiel Rook <michiel@trendserver.nl> 
    29  * @version $Id: IoncubeEncoderTask.php,v 1.6 2006/02/03 10:39:23 mrook Exp
     29 * @version $Id
    3030 * @package phing.tasks.ext.ioncube 
    3131 * @since 2.2.0 
  • branches/2.2/classes/phing/tasks/ext/ioncube/IoncubeLicenseTask.php

    • Property svn:keywords set to author date id revision
    r1 r59  
    11<?php 
    22/** 
    3  * $Id: IoncubeLicenseTask.php,v 1.1 2006/01/30 10:32:35 mrook Exp
     3 * $Id
    44 * 
    55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     
    2727 * 
    2828 * @author Michiel Rook <michiel@trendserver.nl> 
    29  * @version $Id: IoncubeLicenseTask.php,v 1.1 2006/01/30 10:32:35 mrook Exp
     29 * @version $Id
    3030 * @package phing.tasks.ext.ioncube 
    3131 * @since 2.2.0