Skip to content

Commit 3ed1c3d

Browse files
authored
Support missing 'message_log' config file attribute. (#434)
Signed-off-by: Henry Cox <[email protected]>
1 parent 6b8acb3 commit 3ed1c3d

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

lib/lcovutil.pm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ my %rc_common = (
10931093
"lcov_branch_coverage" => \$lcovutil::br_coverage,
10941094
"ignore_errors" => \@rc_ignore,
10951095
"max_message_count" => \$lcovutil::suppressAfter,
1096+
"message_log" => \$lcovutil::message_log,
10961097
'expected_message_count' => \@rc_expected_msg_counts,
10971098
'stop_on_error' => \$lcovutil::stop_on_error,
10981099
'treat_warning_as_error' => \$lcovutil::treat_warning_as_error,
@@ -1305,13 +1306,22 @@ sub read_config($$)
13051306
'config file inclusion loop detected: "' .
13061307
join('" -> "', @include_stack) .
13071308
'" -> "' . $filename . '"');
1308-
return 0;
1309+
# this line is unreachable as we can't ignore the 'usage' error
1310+
# because it is generated when we parse the config-file options
1311+
# but the '--ignore-errors' option isn't parsed until later, after
1312+
# the GetOptions call.
1313+
# This could be fixed by doing some early processing on the command
1314+
# line (similar to how config file options are handled) - but that
1315+
# seems like overkill. Just force the user to fix the issues.
1316+
return 0; # LCOV_UNREACHABLE_LINE
13091317
}
13101318

13111319
if (!open(HANDLE, "<", $filename)) {
13121320
lcovutil::ignorable_error($lcovutil::ERROR_USAGE,
13131321
"cannot read configuration file '$filename': $!");
1314-
return 0; # didn't set anything
1322+
# similarly, this line is also unreachable for the same reasons as
1323+
# described above.
1324+
return 0; # didn't set anything LCOV_UNREACHABLE_LINE
13151325
}
13161326
$included_config_files{abs_path($filename)} = 1;
13171327
push(@include_stack, $filename);

man/lcovrc.5

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,20 @@ This option is used by genhtml, lcov, and geninfo.
11471147

11481148
.PP
11491149

1150+
.BR message_log " ="
1151+
.IR filename
1152+
.IP
1153+
Specify location to store error and warning messages (in addition to writing to STDERR).
1154+
If not specified, then the default location is used.
1155+
.br
1156+
1157+
.br
1158+
This attribute is equivalent to the
1159+
.I \-\-msg\-log
1160+
command line option. The command line option takes precedence if both are specified.
1161+
1162+
.PP
1163+
11501164
.BR stop_on_error " = "
11511165
.IR 0|1
11521166
.IP

tests/gendiffcov/errs/msgtest.sh

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set +x
33

44
source ../../common.tst
55

6-
rm -f test.cpp *.gcno *.gcda a.out *.info *.log *.json diff.txt loop*.rc markers.err*
6+
rm -f test.cpp *.gcno *.gcda a.out *.info *.log *.json diff.txt loop*.rc markers.err* readThis.rc testing.rc
77
rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context labels sortTables
88

99
clean_cover
@@ -172,6 +172,12 @@ if [ 0 != $? ] ; then
172172
fi
173173
echo lcov $LCOV_OPTS --summary initial.info --prune --ignore usage
174174
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --prune --ignore usgae 2>&1 | tee prune_warn.log
175+
if [ 0 != $? ] ; then
176+
echo "ERROR: lcov prune faled"
177+
if [ 0 == $KEEP_GOING ] ; then
178+
exit 1
179+
fi
180+
fi
175181
176182
echo lcov $LCOV_OPTS --capture -d . -o build.info --build-dir x/y
177183
$COVER $LCOV_TOOL $LCOV_OPTS --capture -d . -o build.info --build-dir x/y 2>&1 | tee build_dir_err.log
@@ -207,7 +213,13 @@ fi
207213
208214
209215
echo lcov $LCOV_OPTS --summary initial.info --config-file noSuchFile --ignore usage
210-
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file noSuchFile --ignore usgae 2>&1 | tee err_missing.log
216+
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file noSuchFile 2>&1 | tee err_missing.log
217+
if [ 0 == ${PIPESTATUS[0]} ] ; then
218+
echo "ERROR: didn't exit after self missing config file error"
219+
if [ 0 == $KEEP_GOING ] ; then
220+
exit 1
221+
fi
222+
fi
211223
grep "cannot read configuration file 'noSuchFile'" err_missing.log
212224
if [ 0 != $? ] ; then
213225
echo "ERROR: missing config file message"
@@ -216,10 +228,34 @@ if [ 0 != $? ] ; then
216228
fi
217229
fi
218230
231+
# read a config file which is there...
232+
echo "message_log = message_file.log" > testing.rc
233+
echo "config_file = testing.rc" > readThis.rc
234+
echo lcov $LCOV_OPTS --summary initial.info --config-file readThis.rc
235+
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file readThis.rc
236+
if [ ! == ${PIPESTATUS[0]} ] ; then
237+
echo "ERROR: didn't read config file"
238+
if [ 0 == $KEEP_GOING ] ; then
239+
exit 1
240+
fi
241+
fi
242+
if [ !-f message_file.log] ; then
243+
echo "ERROR: didn't honor message_log"
244+
if [ 0 == $KEEP_GOING ] ; then
245+
exit 1
246+
fi
247+
fi
248+
219249
# loop in config file inclusion
220250
echo "config_file = loop1.rc" > loop1.rc
221251
echo lcov $LCOV_OPTS --summary initial.info --config-file loop1.rc --ignore usage
222252
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file loop1.rc --ignore usage 2>&1 | tee err_selfloop.log
253+
if [ 0 == ${PIPESTATUS[0]} ] ; then
254+
echo "ERROR: skipped self loop error - which isn't supposed to be possible right now"
255+
if [ 0 == $KEEP_GOING ] ; then
256+
exit 1
257+
fi
258+
fi
223259
grep "config file inclusion loop" err_selfloop.log
224260
if [ 0 != $? ] ; then
225261
echo "ERROR: missing config file message"
@@ -232,6 +268,12 @@ echo "config_file = loop3.rc" > loop2.rc
232268
echo 'config_file = $ENV{PWD}/loop2.rc' > loop3.rc
233269
echo lcov $LCOV_OPTS --summary initial.info --config-file loop2.rc --ignore usage
234270
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file loop2.rc --ignore usage 2>&1 | tee err_loop.log
271+
if [ 0 == ${PIPESTATUS[0]} ] ; then
272+
echo "ERROR: skipped self loop error2 - which isn't supposed to be possible"
273+
if [ 0 == $KEEP_GOING ] ; then
274+
exit 1
275+
fi
276+
fi
235277
grep "config file inclusion loop" err_loop.log
236278
if [ 0 != $? ] ; then
237279
echo "ERROR: missing config file message"

0 commit comments

Comments
 (0)