Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new option --disable-coverage-php to skip coverage.serialized report #6761

Open
wants to merge 1 commit into
base: 5.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions src/Codeception/Codecept.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,34 @@ class Codecept
protected ExtensionLoader $extensionLoader;

protected array $options = [
'silent' => false,
'debug' => false,
'steps' => false,
'html' => false,
'xml' => false,
'phpunit-xml' => false,
'no-redirect' => true,
'report' => false,
'colors' => false,
'coverage' => false,
'coverage-xml' => false,
'coverage-html' => false,
'coverage-text' => false,
'coverage-crap4j' => false,
'coverage-cobertura' => false,
'coverage-phpunit' => false,
'groups' => null,
'excludeGroups' => null,
'filter' => null,
'shard' => null,
'env' => null,
'fail-fast' => 0,
'ansi' => true,
'verbosity' => 1,
'interactive' => true,
'no-rebuild' => false,
'quiet' => false,
'silent' => false,
'debug' => false,
'steps' => false,
'html' => false,
'xml' => false,
'phpunit-xml' => false,
'no-redirect' => true,
'report' => false,
'colors' => false,
'coverage' => false,
'coverage-xml' => false,
'coverage-html' => false,
'coverage-text' => false,
'coverage-crap4j' => false,
'coverage-cobertura' => false,
'coverage-phpunit' => false,
'disable-coverage-php' => false,
'groups' => null,
'excludeGroups' => null,
'filter' => null,
'shard' => null,
'env' => null,
'fail-fast' => 0,
'ansi' => true,
'verbosity' => 1,
'interactive' => true,
'no-rebuild' => false,
'quiet' => false,
];

protected array $config = [];
Expand Down
74 changes: 41 additions & 33 deletions src/Codeception/Command/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,39 +89,40 @@
*
* Options:
* -o, --override=OVERRIDE Override config values (multiple values allowed)
* --config (-c) Use custom path for config
* --report Show output in compact style
* --html Generate html with results (default: "report.html")
* --xml Generate JUnit XML Log (default: "report.xml")
* --phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml")
* --no-redirect Do not redirect to Composer-installed version in vendor/codeception
* --colors Use colors in output
* --no-colors Force no colors in output (useful to override config file)
* --silent Only outputs suite names and final results. Almost the same as `--quiet`
* --steps Show steps in output
* --debug (-d) Alias for `-vv`
* --bootstrap Execute bootstrap script before the test
* --coverage Run with code coverage (default: "coverage.serialized")
* --coverage-html Generate CodeCoverage HTML report in path (default: "coverage")
* --coverage-xml Generate CodeCoverage XML report in file (default: "coverage.xml")
* --coverage-text Generate CodeCoverage text report in file (default: "coverage.txt")
* --coverage-phpunit Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
* --coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
* --no-exit Don't finish with exit code
* --group (-g) Groups of tests to be executed (multiple values allowed)
* --skip (-s) Skip selected suites (multiple values allowed)
* --skip-group (-x) Skip selected groups (multiple values allowed)
* --env Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
* --fail-fast (-f) Stop after nth failure (defaults to 1)
* --no-rebuild Do not rebuild actor classes on start
* --help (-h) Display this help message.
* --quiet (-q) Do not output any message. Almost the same as `--silent`
* --verbose (-v|vv|vvv) Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal debug
* --version (-V) Display this application version.
* --ansi Force ANSI output.
* --no-ansi Disable ANSI output.
* --no-interaction (-n) Do not ask any interactive question.
* --seed Use the given seed for shuffling tests
* --config (-c) Use custom path for config
* --report Show output in compact style
* --html Generate html with results (default: "report.html")
* --xml Generate JUnit XML Log (default: "report.xml")
* --phpunit-xml Generate PhpUnit XML Log (default: "phpunit-report.xml")
* --no-redirect Do not redirect to Composer-installed version in vendor/codeception
* --colors Use colors in output
* --no-colors Force no colors in output (useful to override config file)
* --silent Only outputs suite names and final results. Almost the same as `--quiet`
* --steps Show steps in output
* --debug (-d) Alias for `-vv`
* --bootstrap Execute bootstrap script before the test
* --coverage Run with code coverage (default: "coverage.serialized")
* --disable-coverage-php Don't generate CodeCoverage report in raw PHP serialized format
* --coverage-html Generate CodeCoverage HTML report in path (default: "coverage")
* --coverage-xml Generate CodeCoverage XML report in file (default: "coverage.xml")
* --coverage-text Generate CodeCoverage text report in file (default: "coverage.txt")
* --coverage-phpunit Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
* --coverage-cobertura Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
* --no-exit Don't finish with exit code
* --group (-g) Groups of tests to be executed (multiple values allowed)
* --skip (-s) Skip selected suites (multiple values allowed)
* --skip-group (-x) Skip selected groups (multiple values allowed)
* --env Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
* --fail-fast (-f) Stop after nth failure (defaults to 1)
* --no-rebuild Do not rebuild actor classes on start
* --help (-h) Display this help message.
* --quiet (-q) Do not output any message. Almost the same as `--silent`
* --verbose (-v|vv|vvv) Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal debug
* --version (-V) Display this application version.
* --ansi Force ANSI output.
* --no-ansi Disable ANSI output.
* --no-interaction (-n) Do not ask any interactive question.
* --seed Use the given seed for shuffling tests
* ```
*
*/
Expand Down Expand Up @@ -247,6 +248,12 @@ protected function configure(): void
'Define random seed for shuffle setting'
),
new InputOption('no-artifacts', '', InputOption::VALUE_NONE, "Don't report about artifacts"),
new InputOption(
'disable-coverage-php',
'',
InputOption::VALUE_NONE,
"Don't generate CodeCoverage report in raw PHP serialized format"
),
]);

parent::configure();
Expand Down Expand Up @@ -313,6 +320,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$userOptions['verbosity'] = $this->output->getVerbosity();
$userOptions['interactive'] = !$input->hasParameterOption(['--no-interaction', '-n']);
$userOptions['ansi'] = (!$input->hasParameterOption('--no-ansi') xor $input->hasParameterOption('ansi'));
$userOptions['disable-coverage-php'] = (bool) $this->options['disable-coverage-php'];

$userOptions['seed'] = $this->options['seed'] ? (int)$this->options['seed'] : rand();
if ($this->options['no-colors'] || !$userOptions['ansi']) {
Expand Down
6 changes: 5 additions & 1 deletion src/Codeception/Coverage/Subscriber/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public function printResult(PrintResultEvent $event): void
$this->printConsole();
}
$this->output->write("Remote CodeCoverage reports are not printed to console\n");
$this->printPHP();
if ($this->options['disable-coverage-php'] === true) {
$this->output->write("PHP serialized report was skipped\n");
} else {
$this->printPHP();
}
$this->output->write("\n");
if ($this->options['coverage-html']) {
$this->printHtml();
Expand Down
13 changes: 12 additions & 1 deletion tests/cli/IncludedCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,28 @@ public function runIncludedWithHtmlOutput(CliGuy $I)

#[Before('moveToIncluded')]
#[Group('coverage')]
public function runIncludedWithCoverage(CliGuy $I)
public function runIncludedWithCoverage(CliGuy $I): void
{
$I->executeCommand('run --coverage-xml');
$I->amInPath('_log');
$I->seeFileFound('coverage.serialized');
$I->seeFileFound('coverage.xml');
//these assertions shrank over the years to be compatible with many versions of php-code-coverage library
$I->seeInThisFile('BillEvans" namespace="');
$I->seeInThisFile('Musician" namespace="');
$I->seeInThisFile('Hobbit" namespace="');
}

#[Before('moveToIncluded')]
#[Group('coverage')]
public function runIncludedWithoutPhpReport(CliGuy $I): void
{
$I->executeCommand('run --coverage-text --disable-coverage-php');
$I->amInPath('_log');
$I->seeFileFound('coverage.txt');
$I->cantSeeFileFound('coverage.serialized');
}

#[Before('moveToIncluded')]
public function buildIncluded(CliGuy $I)
{
Expand Down
Loading