Skip to content

Commit

Permalink
Merge pull request #8 from vemaeg/feature/allow-use-of-coverage-cache…
Browse files Browse the repository at this point in the history
…-folder

New option to define the code coverage cache directory.
  • Loading branch information
thirsch authored Aug 26, 2022
2 parents af09743 + 1c4c2d2 commit fab082e
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,
InputOption::VALUE_NONE,
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 fab082e

Please sign in to comment.