Skip to content

Commit 507240d

Browse files
committed
Cosmetics and adjust the pear2/all thing to also allow people to use pear2 dir directly if people want to populate /all (they provide the same in most cases, just with /trunk added really)
1 parent c01db2d commit 507240d

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

test-modified.php

+25-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22
namespace {
3-
$path = false;
4-
$force = false;
5-
$norender = false;
3+
$norender = $force = $path = false;
64
if (isset($_SERVER['argv'][1])) {
75
$arg = $_SERVER['argv'][1];
86
if ($arg === '--force') {
97
$force = true;
108
if (!isset($_SERVER['argv'][2])) {
119
goto skippy;
1210
}
11+
1312
// check if we only want to rebuild the coverage db
1413
if ($_SERVER['argv'][2] === '--norender') {
1514
$norender = true;
@@ -25,6 +24,7 @@
2524
if (!isset($_SERVER['argv'][2])) {
2625
goto skippy;
2726
}
27+
2828
if ($_SERVER['argv'][2] === '--force') {
2929
$force = true;
3030
if (!isset($_SERVER['argv'][3])) {
@@ -35,15 +35,23 @@
3535
$arg = $_SERVER['argv'][2];
3636
}
3737
}
38-
$path = realpath($arg);
39-
if ($path) {
40-
$path = realpath($path . '/Pyrus_Developer/src/Pyrus/Developer/CoverageAnalyzer');
38+
39+
$realpath = realpath($arg);
40+
if ($realpath) {
41+
$path = realpath($realpath . '/Pyrus_Developer/src/Pyrus/Developer/CoverageAnalyzer');
4142
}
43+
44+
if ($realpath && !$path) {
45+
$path = realpath($realpath . '/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer');
46+
}
47+
4248
}
49+
4350
skippy:
4451
if (!$path) {
4552
$path = realpath(__DIR__ . '/../all/Pyrus_Developer/src/Pyrus/Developer/CoverageAnalyzer');
4653
}
54+
4755
if (!$path) {
4856
die("Usage:
4957
php test-modified.php [--force] [--norender] [/path/to/all]
@@ -56,12 +64,14 @@
5664
by default, we assume ../all
5765
");
5866
}
67+
5968
function __autoload($c)
6069
{
6170
$c = str_replace(array('PEAR2\Pyrus\Developer\CoverageAnalyzer\\',
6271
'\\'), array('', '/'), $c);
6372
include $GLOBALS['path'] . '/' . $c . '.php';
6473
}
74+
6575
$e = error_reporting();
6676
error_reporting(0);
6777
$olddir = getcwd();
@@ -78,28 +88,33 @@ function __autoload($c)
7888
break;
7989
}
8090
}
91+
8192
if (!isset($codepath)) {
8293
die("Something is wrong - PEAR.php exists, but was not within include_path\n");
8394
}
95+
8496
require_once 'PEAR/Command/Test.php';
8597
require_once 'PEAR/Frontend/CLI.php';
8698
require_once 'PEAR/Config.php';
87-
$cli = new PEAR_Frontend_CLI;
99+
$cli = new PEAR_Frontend_CLI;
88100
$config = @PEAR_Config::singleton();
89-
$test = new PEAR_Command_Test($cli, $config);
101+
$test = new PEAR_Command_Test($cli, $config);
90102
error_reporting($e);
91103
chdir($olddir);
92104
}
105+
93106
namespace PEAR2\Pyrus\Developer\CoverageAnalyzer {
94107
$sqlite = new Sqlite($testpath . '/pear2coverage.db', $codepath, $testpath);
95108
$modified = $sqlite->getModifiedTests();
96109
if (!$force && !count($modified)) {
97110
echo "No changes to coverage needed. Bye!\n";
98111
exit;
99112
}
113+
100114
if (!count($modified) && $force) {
101115
goto norunnie;
102116
}
117+
103118
chdir($testpath);
104119
$e = error_reporting();
105120
error_reporting(0);
@@ -118,6 +133,7 @@ function __autoload($c)
118133
if ($norender) {
119134
exit;
120135
}
136+
121137
if (file_exists(__DIR__ . '/coverage')) {
122138
echo "Removing old coverage HTML...";
123139
foreach (new \DirectoryIterator(__DIR__ . '/coverage') as $file) {
@@ -128,6 +144,7 @@ function __autoload($c)
128144
} else {
129145
mkdir(__DIR__ . '/coverage');
130146
}
147+
131148
echo "Rendering\n";
132149
$a->render(__DIR__ . '/coverage');
133150
echo "Done rendering\n";

0 commit comments

Comments
 (0)