1
1
<?php
2
2
namespace {
3
- $ path = false ;
4
- $ force = false ;
5
- $ norender = false ;
3
+ $ norender = $ force = $ path = false ;
6
4
if (isset ($ _SERVER ['argv ' ][1 ])) {
7
5
$ arg = $ _SERVER ['argv ' ][1 ];
8
6
if ($ arg === '--force ' ) {
9
7
$ force = true ;
10
8
if (!isset ($ _SERVER ['argv ' ][2 ])) {
11
9
goto skippy;
12
10
}
11
+
13
12
// check if we only want to rebuild the coverage db
14
13
if ($ _SERVER ['argv ' ][2 ] === '--norender ' ) {
15
14
$ norender = true ;
25
24
if (!isset ($ _SERVER ['argv ' ][2 ])) {
26
25
goto skippy;
27
26
}
27
+
28
28
if ($ _SERVER ['argv ' ][2 ] === '--force ' ) {
29
29
$ force = true ;
30
30
if (!isset ($ _SERVER ['argv ' ][3 ])) {
35
35
$ arg = $ _SERVER ['argv ' ][2 ];
36
36
}
37
37
}
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 ' );
41
42
}
43
+
44
+ if ($ realpath && !$ path ) {
45
+ $ path = realpath ($ realpath . '/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer ' );
46
+ }
47
+
42
48
}
49
+
43
50
skippy:
44
51
if (!$ path ) {
45
52
$ path = realpath (__DIR__ . '/../all/Pyrus_Developer/src/Pyrus/Developer/CoverageAnalyzer ' );
46
53
}
54
+
47
55
if (!$ path ) {
48
56
die ("Usage:
49
57
php test-modified.php [--force] [--norender] [/path/to/all]
56
64
by default, we assume ../all
57
65
" );
58
66
}
67
+
59
68
function __autoload ($ c )
60
69
{
61
70
$ c = str_replace (array ('PEAR2\Pyrus\Developer\CoverageAnalyzer \\' ,
62
71
'\\' ), array ('' , '/ ' ), $ c );
63
72
include $ GLOBALS ['path ' ] . '/ ' . $ c . '.php ' ;
64
73
}
74
+
65
75
$ e = error_reporting ();
66
76
error_reporting (0 );
67
77
$ olddir = getcwd ();
@@ -78,28 +88,33 @@ function __autoload($c)
78
88
break ;
79
89
}
80
90
}
91
+
81
92
if (!isset ($ codepath )) {
82
93
die ("Something is wrong - PEAR.php exists, but was not within include_path \n" );
83
94
}
95
+
84
96
require_once 'PEAR/Command/Test.php ' ;
85
97
require_once 'PEAR/Frontend/CLI.php ' ;
86
98
require_once 'PEAR/Config.php ' ;
87
- $ cli = new PEAR_Frontend_CLI ;
99
+ $ cli = new PEAR_Frontend_CLI ;
88
100
$ config = @PEAR_Config::singleton ();
89
- $ test = new PEAR_Command_Test ($ cli , $ config );
101
+ $ test = new PEAR_Command_Test ($ cli , $ config );
90
102
error_reporting ($ e );
91
103
chdir ($ olddir );
92
104
}
105
+
93
106
namespace PEAR2 \Pyrus \Developer \CoverageAnalyzer {
94
107
$ sqlite = new Sqlite ($ testpath . '/pear2coverage.db ' , $ codepath , $ testpath );
95
108
$ modified = $ sqlite ->getModifiedTests ();
96
109
if (!$ force && !count ($ modified )) {
97
110
echo "No changes to coverage needed. Bye! \n" ;
98
111
exit ;
99
112
}
113
+
100
114
if (!count ($ modified ) && $ force ) {
101
115
goto norunnie;
102
116
}
117
+
103
118
chdir ($ testpath );
104
119
$ e = error_reporting ();
105
120
error_reporting (0 );
@@ -118,6 +133,7 @@ function __autoload($c)
118
133
if ($ norender ) {
119
134
exit ;
120
135
}
136
+
121
137
if (file_exists (__DIR__ . '/coverage ' )) {
122
138
echo "Removing old coverage HTML... " ;
123
139
foreach (new \DirectoryIterator (__DIR__ . '/coverage ' ) as $ file ) {
@@ -128,6 +144,7 @@ function __autoload($c)
128
144
} else {
129
145
mkdir (__DIR__ . '/coverage ' );
130
146
}
147
+
131
148
echo "Rendering \n" ;
132
149
$ a ->render (__DIR__ . '/coverage ' );
133
150
echo "Done rendering \n" ;
0 commit comments