Skip to content

Commit

Permalink
Return non-zero exit code if error(s) detected when --keep-going
Browse files Browse the repository at this point in the history
flag is set.

Signed-off-by:  Henry Cox <[email protected]>
  • Loading branch information
henry2cox committed Oct 19, 2023
1 parent a8fdeca commit 59f24d0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions bin/genhtml
Original file line number Diff line number Diff line change
Expand Up @@ -5754,6 +5754,10 @@ if (0 == $exit_status &&
}

lcovutil::save_profile(File::Spec->catfile($output_directory, 'genhtml'));
# exit with non-zero status if --keep-going and some errors detected
$exit_status = 1
if (0 == $exit_status &&
lcovutil::saw_error());

exit($exit_status);

Expand Down
4 changes: 4 additions & 0 deletions bin/geninfo
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ lcovutil::save_profile(
(defined($output_filename) && '-' ne $output_filename) ? $output_filename :
"geninfo");

# exit with non-zero status if --keep-going and some errors detected
$exit_code = 1
if (0 == $exit_code &&
lcovutil::saw_error());
exit($exit_code);

#
Expand Down
5 changes: 5 additions & 0 deletions bin/lcov
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ $lcovutil::profileData{total} = $end - $begin;
lcovutil::save_profile($output_filename ? $output_filename : "lcov")
unless $lcovutil::lcov_capture;

# exit with non-zero status if --keep-going and some errors detected
$exit_code = 1
if (0 == $exit_code &&
lcovutil::saw_error());

exit($exit_code);

#
Expand Down
7 changes: 7 additions & 0 deletions lib/lcovutil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,13 @@ sub _count_message($$)
++$message_types{$type}{$name};
}

sub saw_error
{
# true if we saw at least one error when 'stop_on_error' is false
# enables us to return non-zero exit status if any errors were detected
return exists($message_types{error});
}

sub ignorable_error($$;$)
{
my ($code, $msg, $quiet) = @_;
Expand Down
11 changes: 9 additions & 2 deletions man/lcovrc.5
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,14 @@ This option is used by genhtml, lcov, and geninfo.
.BR stop_on_error " = "
.IR 0|1
.IP
If set to 1, tell the tools to ignore errors and keep going to try to generate a result - however flawed or incomplete that result might be.
If set to 0, tell the tools to ignore errors and keep going to try to generate a result - however flawed or incomplete that result might be.
Note that ignoring some errors may lead to other errors.
.br
The tool will return a non-zero exit code if one or more errors are detected
during execution when
.I stop_on_error
is disabled. That is, the tool will continue execution in the presence
of errors but will return an exit status.

.br

Expand All @@ -830,10 +836,11 @@ Default is 1: stop when error occurs.

If the
.I 'ignore_error msgType'
option is also used, then those messages will be treated as warnings rather than errors (or will be entirely suppressed if the message type appears multiple times in the ignore_messages option).
option is also used, then those messages will be treated as warnings rather than errors (or will be entirely suppressed if the message type appears multiple times in the ignore_messages option). Warnings do not cause a non-zero exit status.

This option is used by genhtml, lcov, and geninfo.


.PP

.BR warn_once_per_file " = "
Expand Down

0 comments on commit 59f24d0

Please sign in to comment.