@@ -85,6 +85,26 @@ public static function main()
8585 )
8686 );
8787
88+ $ input ->registerOption (
89+ new ezcConsoleOption (
90+ '' ,
91+ 'blacklist ' ,
92+ ezcConsoleInput::TYPE_STRING ,
93+ array (),
94+ TRUE
95+ )
96+ );
97+
98+ $ input ->registerOption (
99+ new ezcConsoleOption (
100+ '' ,
101+ 'whitelist ' ,
102+ ezcConsoleInput::TYPE_STRING ,
103+ array (),
104+ TRUE
105+ )
106+ );
107+
88108 $ input ->registerOption (
89109 new ezcConsoleOption (
90110 'h ' ,
@@ -141,21 +161,41 @@ public static function main()
141161 $ arguments = $ input ->getArguments ();
142162 $ clover = $ input ->getOption ('clover ' )->value ;
143163 $ html = $ input ->getOption ('html ' )->value ;
164+ $ blacklist = $ input ->getOption ('blacklist ' )->value ;
165+ $ whitelist = $ input ->getOption ('whitelist ' )->value ;
144166
145167 if (count ($ arguments ) == 1 ) {
146168 self ::printVersionString ();
147169
148170 $ coverage = new PHP_CodeCoverage ;
149-
150- $ class = new ReflectionClass ('ezcBase ' );
151- $ coverage ->filter ()->addDirectoryToBlacklist (
152- dirname ($ class ->getFileName ())
153- );
154-
155- $ class = new ReflectionClass ('ezcConsoleInput ' );
156- $ coverage ->filter ()->addDirectoryToBlacklist (
157- dirname ($ class ->getFileName ())
158- );
171+ $ filter = $ coverage ->filter ();
172+
173+ if (empty ($ whitelist )) {
174+ $ c = new ReflectionClass ('ezcBase ' );
175+ $ filter ->addDirectoryToBlacklist (dirname ($ c ->getFileName ()));
176+ $ c = new ReflectionClass ('ezcConsoleInput ' );
177+ $ filter ->addDirectoryToBlacklist (dirname ($ c ->getFileName ()));
178+
179+ foreach ($ blacklist as $ item ) {
180+ if (is_dir ($ item )) {
181+ $ filter ->addDirectoryToBlacklist ($ item );
182+ }
183+
184+ else if (is_dir ($ item )) {
185+ $ filter ->addFileToBlacklist ($ item );
186+ }
187+ }
188+ } else {
189+ foreach ($ whitelist as $ item ) {
190+ if (is_dir ($ item )) {
191+ $ filter ->addDirectoryToWhitelist ($ item );
192+ }
193+
194+ else if (is_dir ($ item )) {
195+ $ filter ->addFileToWhitelist ($ item );
196+ }
197+ }
198+ }
159199
160200 $ coverage ->start ('phpcov ' );
161201
@@ -206,11 +246,14 @@ protected static function showHelp()
206246 print <<<EOT
207247Usage: phpcov [switches] <file>
208248
209- --clover <file> Write code coverage data in Clover XML format.
210- --html <dir> Generate code coverage report in HTML format.
249+ --clover <file> Write code coverage data in Clover XML format.
250+ --html <dir> Generate code coverage report in HTML format.
251+
252+ --blacklist <dir|file> Adds <dir|file> to the blacklist.
253+ --whitelist <dir|file> Adds <dir|file> to the whitelist.
211254
212- --help Prints this usage information.
213- --version Prints the version and exits.
255+ --help Prints this usage information.
256+ --version Prints the version and exits.
214257
215258EOT
216259;
0 commit comments