Skip to content

Commit 63c3dc9

Browse files
committed
Add 'treat_warning_as_error' support.
Signed-off-by: Henry Cox <[email protected]>
1 parent 55e826c commit 63c3dc9

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

bin/geninfo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,11 @@ sub find_files
932932
}
933933
foreach my $directory (@_) {
934934
unless (-e $directory) {
935-
# hold error until the end of processing...
935+
# hold error until the end of processing - we might be looking
936+
# for both .gcno and .gcda files - and don't want to generate
937+
# the same 'no such directory' message twice. Nor do we want
938+
# to produce an error if only one type of file is in this
939+
# directory
936940
$self->[2]->{$directory} = [$lcovutil::ERROR_USAGE,
937941
"no such file or directory '$directory'"
938942
];
@@ -961,6 +965,7 @@ sub find_files
961965
my @found = split(' ', $stdout);
962966
if (!@found) {
963967
if (!defined($processGcno) || $processGcno != 2) {
968+
# delay message: might be a file of other type here
964969
$self->[2]->{$directory} = [
965970
$lcovutil::ERROR_EMPTY,
966971
"no $ext files found in $directory"
@@ -969,6 +974,7 @@ sub find_files
969974

970975
next;
971976
}
977+
# we found something here - remove the pending error message, if any
972978
delete($self->[2]->{$directory})
973979
; # if exists($self->[2]->{$directory});
974980
lcovutil::info("Found %d %s files in %s\n",

lcovrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ max_message_count = 100
6464
# See the man pages for more detail
6565
#stop_on_error = 1
6666

67+
# If nonzero, treat warnings as error
68+
# note that ignored messages will still appear as warnings
69+
# Default is 0
70+
#treat_warning_as_error = 1
71+
6772
# If set to non-zero, only issue particluar warning once per file
6873
# Default is 1
6974
#warn_once_per_file = 1

lib/lcovutil.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ my @lcovErrs = (["annotate", \$ERROR_ANNOTATE_SCRIPT],
186186
our %lcovErrors;
187187

188188
our $stop_on_error; # attempt to keep going
189-
our $warn_once_per_file = 1;
189+
our $treat_warning_as_error = 0;
190+
our $warn_once_per_file = 1;
190191
our $excessive_count_threshold; # default not set: don't check
191192

192193
our $br_coverage = 0; # If set, generate branch coverage statistics
@@ -1075,6 +1076,7 @@ my %rc_common = (
10751076
"ignore_errors" => \@rc_ignore,
10761077
"max_message_count" => \$lcovutil::suppressAfter,
10771078
'stop_on_error' => \$lcovutil::stop_on_error,
1079+
'treat_warning_as_error' => \$lcovutil::treat_warning_as_error,
10781080
'warn_once_per_file' => \$lcovutil::warn_once_per_file,
10791081
"rtl_file_extensions" => \$rtlExtensions,
10801082
"c_file_extensions" => \$cExtensions,
@@ -1969,6 +1971,10 @@ sub ignorable_error($$;$)
19691971
sub ignorable_warning($$;$)
19701972
{
19711973
my ($code, $msg, $quiet) = @_;
1974+
if ($lcovutil::treat_warning_as_error) {
1975+
ignorable_error($code, $msg, $quiet);
1976+
return;
1977+
}
19721978
die("undefined error code for '$msg'") unless defined($code);
19731979

19741980
my $errName = "code_$code";

man/lcovrc.5

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ genhtml_med_limit = 75
182182
max_message_count = 100
183183

184184
.br
185-
# If set, do not stop when an 'ignorable error' occurs - try
185+
# If nonzero, do not stop when an 'ignorable error' occurs - try
186186
.br
187187
# to generate a result, however flawed. This is equivalent to
188188
.br
@@ -192,7 +192,17 @@ max_message_count = 100
192192
.br
193193
#stop_on_error = 1
194194

195-
# If set to non-zero, only issue particluar warning once per file
195+
.br
196+
# If nonzero, treat warnings as error
197+
.br
198+
# note that ignored messages will still appear as warnings
199+
.br
200+
# Default is 0
201+
.br
202+
#treat_warning_as_error = 1
203+
204+
.br
205+
# If set to non-zero, only issue particular warning once per file
196206
.br
197207
# Default is 1
198208
.br
@@ -978,6 +988,22 @@ option is also used, then those messages will be treated as warnings rather than
978988
This option is used by genhtml, lcov, and geninfo.
979989

980990

991+
.PP
992+
993+
.BR treat_warning_as_error " = "
994+
.IR 0|1
995+
.IP
996+
If set to 1, tell the tools that messages which are normally treated as
997+
warnings (
998+
.I e.g.,
999+
certain usage messages) should be treated as errors.
1000+
1001+
Note that ignored messages will still appear as warnings: see the
1002+
.I ignore_errors
1003+
entry, above.
1004+
1005+
This option is used by genhtml, lcov, and geninfo.
1006+
9811007
.PP
9821008

9831009
.BR warn_once_per_file " = "

0 commit comments

Comments
 (0)