Skip to content

Commit 59f24d0

Browse files
committed
Return non-zero exit code if error(s) detected when --keep-going
flag is set. Signed-off-by: Henry Cox <[email protected]>
1 parent a8fdeca commit 59f24d0

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

bin/genhtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5754,6 +5754,10 @@ if (0 == $exit_status &&
57545754
}
57555755

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

57585762
exit($exit_status);
57595763

bin/geninfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,10 @@ lcovutil::save_profile(
652652
(defined($output_filename) && '-' ne $output_filename) ? $output_filename :
653653
"geninfo");
654654

655+
# exit with non-zero status if --keep-going and some errors detected
656+
$exit_code = 1
657+
if (0 == $exit_code &&
658+
lcovutil::saw_error());
655659
exit($exit_code);
656660

657661
#

bin/lcov

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ $lcovutil::profileData{total} = $end - $begin;
449449
lcovutil::save_profile($output_filename ? $output_filename : "lcov")
450450
unless $lcovutil::lcov_capture;
451451

452+
# exit with non-zero status if --keep-going and some errors detected
453+
$exit_code = 1
454+
if (0 == $exit_code &&
455+
lcovutil::saw_error());
456+
452457
exit($exit_code);
453458

454459
#

lib/lcovutil.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,13 @@ sub _count_message($$)
16381638
++$message_types{$type}{$name};
16391639
}
16401640

1641+
sub saw_error
1642+
{
1643+
# true if we saw at least one error when 'stop_on_error' is false
1644+
# enables us to return non-zero exit status if any errors were detected
1645+
return exists($message_types{error});
1646+
}
1647+
16411648
sub ignorable_error($$;$)
16421649
{
16431650
my ($code, $msg, $quiet) = @_;

man/lcovrc.5

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,14 @@ This option is used by genhtml, lcov, and geninfo.
817817
.BR stop_on_error " = "
818818
.IR 0|1
819819
.IP
820-
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.
820+
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.
821821
Note that ignoring some errors may lead to other errors.
822+
.br
823+
The tool will return a non-zero exit code if one or more errors are detected
824+
during execution when
825+
.I stop_on_error
826+
is disabled. That is, the tool will continue execution in the presence
827+
of errors but will return an exit status.
822828

823829
.br
824830

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

831837
If the
832838
.I 'ignore_error msgType'
833-
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).
839+
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.
834840

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

843+
837844
.PP
838845

839846
.BR warn_once_per_file " = "

0 commit comments

Comments
 (0)