cvs: pear-core / test-modified.php

From: Date: Sat, 11 Apr 2009 05:03:26 +0000
Subject: cvs: pear-core / test-modified.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-8321@lists.php.net to get a copy of this message
cellog Sat Apr 11 05:03:26 2009 UTC Added files: /pear-core test-modified.php Log: add code coverage generation script. This requires either that your development dir structure is: pear-core/ all/ or that you pass in the full path to all/ It also will not cover PEAR.php, System.php or any other top-level file (in order to avoid counting test files as source) run as: php test-modified.php after an initial run of pear run-tests -rx tests http://cvs.php.net/viewvc.cgi/pear-core/test-modified.php?view=markup&rev=1.1 Index: pear-core/test-modified.php +++ pear-core/test-modified.php <?php namespace { $path = false; $force = false; if (isset($_SERVER['argv'][1])) { $arg = $_SERVER['argv'][1]; if ($arg === '--force') { $force = true; if (!isset($_SERVER['argv'][2])) { goto skippy; } $arg = $_SERVER['argv'][2]; } $path = realpath($arg); if ($path) { $path = realpath($path . '/Pyrus_Developer/src/Pyrus/Developer/CoverageAnalyzer'); } } skippy: if (!$path) { $path = realpath(__DIR__ . '/../all/Pyrus_Developer/src/Pyrus/Developer/CoverageAnalyzer'); } if (!$path) { die("Usage: php test-modified.php --force Generate coverage even if no changes or failed tests php test-modified.php /path/to/all Pass in path to checkout of http://svn.pear.php.net/PEAR2/all, by default, we assume ../all php test-modified.php --force /path/to/all Force coverage generation and pass in path to all "); } function __autoload($c) { $c = str_replace(array('PEAR2\Pyrus\Developer\CoverageAnalyzer\\', '\\'), array('', '/'), $c); include $GLOBALS['path'] . '/' . $c . '.php'; } $e = error_reporting(); error_reporting(0); require_once 'PEAR/Command/Test.php'; require_once 'PEAR/Frontend/CLI.php'; require_once 'PEAR/Config.php'; $cli = new PEAR_Frontend_CLI; $config = @PEAR_Config::singleton(); $test = new PEAR_Command_Test($cli, $config); error_reporting($e); } namespace PEAR2\Pyrus\Developer\CoverageAnalyzer { $codepath = realpath(__DIR__ . '/PEAR'); $testpath = realpath(__DIR__ . '/tests'); $sqlite = new Sqlite($codepath, $testpath . '/pear2coverage.db'); $modified = $sqlite->getModifiedTests(); if (!$force && !count($modified)) { echo "No changes to coverage needed. Bye!\n"; exit; } if (!count($modified) && $force) { goto norunnie; } $dir = getcwd(); chdir($testpath); error_reporting(0); $test->doRunTests('run-tests', array('coverage' => true), $modified); error_reporting($e); chdir($dir); if (!$force && file_exists($testpath . '/run-tests.log')) { // tests failed echo "Tests failed - not regenerating coverage data\n"; exit; } norunnie: $a = new Aggregator($testpath, $codepath, $testpath . '/pear2coverage.db'); if (file_exists(__DIR__ . '/test')) { foreach (new \DirectoryIterator(__DIR__ . '/test') as $file) { if ($file->isDot()) continue; unlink($file->getPathName()); } } else { mkdir(__DIR__ . '/coverage'); } echo "Rendering\n"; $a->render(__DIR__ . '/coverage'); echo "Done rendering\n"; } ?>

« previous php.pear.core (#8321) next »