Skip to content

Commit 066a20e

Browse files
committed
Add options ignore-red-metrics-on-exit, ignore-yellow-metrics-on-exit
1 parent b762082 commit 066a20e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/PHPUnit/Cobertura/Formatter/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ private function doRun(): int
8383

8484
private function calculateExitCode(): int
8585
{
86-
if ($this->processor->colorizerStats->isRed()) {
86+
if ($this->processor->colorizerStats->isRed() && !$this->commandLine->optionIgnoreRedMetricsOnExit()) {
8787
return self::EXIT_CODE_RED_METRICS;
8888
}
8989

90-
if ($this->processor->colorizerStats->isYellow()) {
90+
if ($this->processor->colorizerStats->isYellow() && !$this->commandLine->optionIgnoreYellowMetricsOnExit()) {
9191
return self::EXIT_CODE_YELLOW_METRICS;
9292
}
9393

src/PHPUnit/Cobertura/Formatter/Config/CommandLine.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ public function buildInputArgs(): void
3131
$definition = new InputDefinition();
3232

3333
$definition->addArguments([
34-
new InputArgument('cobertura-file', InputArgument::OPTIONAL)
34+
new InputArgument('cobertura-file', InputArgument::OPTIONAL),
3535
]);
3636

3737
$definition->addOptions([
3838
new InputOption('init', null, InputOption::VALUE_NONE),
39-
new InputOption('no-color', null, InputOption::VALUE_NONE),
4039
new InputOption('filter-class-name', null, InputOption::VALUE_REQUIRED),
4140
new InputOption('config-file', null, InputOption::VALUE_REQUIRED),
41+
new InputOption('no-color', null, InputOption::VALUE_NONE),
42+
new InputOption('ignore-red-metrics-on-exit', null, InputOption::VALUE_NONE),
43+
new InputOption('ignore-yellow-metrics-on-exit', null, InputOption::VALUE_NONE)
4244
]);
4345

4446
$this->input = new ArgvInput(null, $definition);
@@ -65,6 +67,16 @@ public function optionNoColor(): bool
6567
return (bool) $this->input->getOption('no-color');
6668
}
6769

70+
public function optionIgnoreRedMetricsOnExit(): bool
71+
{
72+
return (bool) $this->input->getOption('ignore-red-metrics-on-exit');
73+
}
74+
75+
public function optionIgnoreYellowMetricsOnExit(): bool
76+
{
77+
return (bool) $this->input->getOption('ignore-yellow-metrics-on-exit');
78+
}
79+
6880
public function optionFilterClassName(): ?string
6981
{
7082
/** @var string|null $filterClassName */

0 commit comments

Comments
 (0)