Skip to content

Commit

Permalink
New option to define the code coverage cache directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
thirsch committed Aug 26, 2022
1 parent 7e30268 commit 1c4c2d2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/PhpunitMerger/Command/CoverageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function configure()
->addOption(
'coverage-cache',
null,
InputArgument::OPTIONAL,
InputOption::VALUE_OPTIONAL,
'The cache directory to be used for the code coverage'
);
}
Expand All @@ -71,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$finder->files()
->in(realpath($input->getArgument('directory')));

$codeCoverage = $this->getCodeCoverage($input->getArgument('coverage-cache'));
$codeCoverage = $this->getCodeCoverage($output, $input->getOption('coverage-cache'));

foreach ($finder as $file) {
$coverage = require $file->getRealPath();
Expand All @@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$codeCoverage->merge($coverage);
}

$this->writeCodeCoverage($codeCoverage, $output, $input->getArgument('file'), $input->getOption('cobertura') ?? false);
$this->writeCodeCoverage($codeCoverage,$output, $input->getArgument('file'), $input->getOption('cobertura') ?? false);
$html = $input->getOption('html');
if ($html !== null) {
$lowUpperBound = (int)($input->getOption('lowUpperBound') ?: 50);
Expand All @@ -92,7 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 0;
}

private function getCodeCoverage($coverageCache = null)
private function getCodeCoverage(OutputInterface $output, $coverageCache = null)
{
$driver = null;
$filter = null;
Expand All @@ -104,6 +104,7 @@ private function getCodeCoverage($coverageCache = null)
$codeCoverage = new CodeCoverage($driver, $filter);

if ($coverageCache) {
$output->writeln('Using directory ' . $coverageCache . ' as coverage cache...');
$codeCoverage->cacheStaticAnalysis($coverageCache);
}

Expand Down

0 comments on commit 1c4c2d2

Please sign in to comment.