Skip to content

Commit

Permalink
Add option to allow skipping logic that exits w/ an error code if war…
Browse files Browse the repository at this point in the history
…nings are detected in the output (#18391)

* Add option to allow skipping the logic that returns an error code if warnings are detected in the output (for automation)

* fix test

* fix test

* Update Console.php
  • Loading branch information
diosmosis authored Nov 29, 2021
1 parent cc6d43a commit e321847
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function __construct(Environment $environment = null)
);

$this->getDefinition()->addOption($option);

$option = new InputOption('ignore-warn', null, InputOption::VALUE_NONE,
'Return 0 exit code even if there are warning logs or error logs detected in the command output.');

$this->getDefinition()->addOption($option);
}

public function renderException($e, $output)
Expand Down Expand Up @@ -132,7 +137,10 @@ private function doRunImpl(InputInterface $input, OutputInterface $output)
}

$importantLogDetector = StaticContainer::get(FailureLogMessageDetector::class);
if ($exitCode === 0 && $importantLogDetector->hasEncounteredImportantLog()) {
if (!$input->hasParameterOption('--ignore-warn')
&& $exitCode === 0
&& $importantLogDetector->hasEncounteredImportantLog()
) {
$output->writeln("Error: error or warning logs detected, exit 1");
$exitCode = 1;
}
Expand Down

0 comments on commit e321847

Please sign in to comment.