15
15
use DigitalRevolution \CodeCoverageInspection \Renderer \TextRenderer ;
16
16
use JsonException ;
17
17
use Symfony \Component \Console \Command \Command ;
18
+ use Symfony \Component \Console \Input \InputArgument ;
18
19
use Symfony \Component \Console \Input \InputInterface ;
19
20
use Symfony \Component \Console \Input \InputOption ;
20
21
use Symfony \Component \Console \Output \OutputInterface ;
25
26
class InspectCommand extends Command
26
27
{
27
28
private ConfigFactory $ configFactory ;
28
- private string $ schemaPath ;
29
+ private string $ schemaPath ;
29
30
30
31
public function __construct (string $ name = null )
31
32
{
@@ -38,7 +39,7 @@ protected function configure(): void
38
39
{
39
40
$ this ->setName ("inspect " )
40
41
->setDescription ("PHPUnit code coverage inspection " )
41
- ->addArgument ('coverage ' , InputOption:: VALUE_REQUIRED , 'Path to phpunit \'s coverage.xml ' )
42
+ ->addArgument ('coverage ' , InputArgument:: REQUIRED | InputArgument:: IS_ARRAY , 'Path to phpunit \'s coverage.xml ' )
42
43
->addOption ('config ' , 'c ' , InputOption::VALUE_REQUIRED , 'Path to configuration file. Optional ' )
43
44
->addOption ('baseDir ' , '' , InputOption::VALUE_REQUIRED , 'Base directory from where to determine the relative config paths ' )
44
45
->addOption ('reportGitlab ' , '' , InputOption::VALUE_OPTIONAL , 'Gitlab output format. To file or if absent to stdout ' , false )
@@ -62,10 +63,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
62
63
// gather data
63
64
$ domConfig = DOMDocumentFactory::getValidatedDOMDocument ($ inputConfig ->getConfigPath (), $ this ->schemaPath );
64
65
$ config = InspectionConfigFactory::fromDOMDocument ($ inputConfig ->getBaseDir (), $ domConfig );
65
- $ metrics = MetricsFactory::getFileMetrics (DOMDocumentFactory::getDOMDocument ($ inputConfig ->getCoverageFilepath ()));
66
66
67
+ $ domDocuments = [];
68
+ foreach ($ inputConfig ->getCoveragesFilepath () as $ coverageFilepath ) {
69
+ $ domDocuments [] = DOMDocumentFactory::getDOMDocument ($ coverageFilepath );
70
+ }
71
+ $ metrics = MetricsFactory::getFilesMetrics ($ domDocuments );
67
72
if (count ($ metrics ) === 0 ) {
68
- $ output ->writeln ("No metrics found in coverage file : " . $ inputConfig ->getCoverageFilepath ( ));
73
+ $ output ->writeln ("No metrics found in coverage files : " . implode ( ' , ' , $ inputConfig ->getCoveragesFilepath () ));
69
74
70
75
return Command::FAILURE ;
71
76
}
0 commit comments