File tree Expand file tree Collapse file tree 3 files changed +40
-5
lines changed
src/CodeClimate/Bundle/TestReporterBundle Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,13 @@ protected function configure()
35
35
null ,
36
36
InputOption::VALUE_NONE ,
37
37
'Do not upload, print JSON payload to stdout '
38
+ )
39
+ ->addOption (
40
+ 'coverage-report ' ,
41
+ null ,
42
+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY ,
43
+ 'Location of clover style CodeCoverage report, as produced by PHPUnit \'s --coverage-clover option. ' ,
44
+ array ('build/logs/clover.xml ' )
38
45
);
39
46
}
40
47
@@ -46,7 +53,7 @@ protected function configure()
46
53
protected function execute (InputInterface $ input , OutputInterface $ output )
47
54
{
48
55
$ ret = 0 ;
49
- $ collector = new CoverageCollector ();
56
+ $ collector = new CoverageCollector ($ input -> getOption ( ' coverage-report ' ) );
50
57
$ json = $ collector ->collectAsJson ();
51
58
52
59
if ($ input ->getOption ('stdout ' )) {
Original file line number Diff line number Diff line change 8
8
9
9
class CoverageCollector
10
10
{
11
- const RELATIVE_PATH = 'build/logs/clover.xml ' ;
12
-
13
11
protected $ api ;
14
12
15
- public function __construct ()
13
+ /**
14
+ * Array that holds list of relative paths to Clover XML files
15
+ * @var array
16
+ */
17
+ protected $ cloverPaths = array ();
18
+
19
+ public function __construct ($ paths )
16
20
{
17
21
$ rootDir = getcwd ();
18
22
$ config = new Configuration ();
19
23
$ config ->setSrcDir ($ rootDir );
20
- $ config ->addCloverXmlPath ($ rootDir . DIRECTORY_SEPARATOR . static ::RELATIVE_PATH );
24
+ $ this ->setCloverPaths ($ paths );
25
+ foreach ($ this ->getCloverPaths () as $ path ) {
26
+ if (file_exists ($ path )) {
27
+ $ config ->addCloverXmlPath ($ path );
28
+ } else {
29
+ $ config ->addCloverXmlPath ($ rootDir . DIRECTORY_SEPARATOR . $ path );
30
+ }
31
+ }
21
32
22
33
$ this ->api = new Jobs ($ config );
23
34
}
24
35
36
+ /**
37
+ * Set a list of Clover XML paths
38
+ * @param array $paths Array of relative paths to Clovers XML files
39
+ */
40
+ public function setCloverPaths ($ paths )
41
+ {
42
+ $ this ->cloverPaths = $ paths ;
43
+ }
44
+
45
+ /**
46
+ * Get a list of Clover XML paths
47
+ * @return array Array of relative Clover XML file locations
48
+ */
49
+ public function getCloverPaths ()
50
+ {
51
+ return $ this ->cloverPaths ;
52
+ }
25
53
public function collectAsJson ()
26
54
{
27
55
$ cloverJsonFile = $ this ->api ->collectCloverXml ()->getJsonFile ();
You can’t perform that action at this time.
0 commit comments