Skip to content

Commit 3b15bf5

Browse files
committed
Look for system config file in $LCOV_HOME/etc/lcovrc.
That is: use environment variable rather than hard-coded '/etc' or '/usr/local/etc'. Signed-off-by: Henry Cox <[email protected]>
1 parent 22e52b2 commit 3b15bf5

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lib/lcovutil.pm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,12 +1263,13 @@ sub apply_rc_params($)
12631263
$set_value |= apply_config(\%rcHash, $config, \%new_opt_rc);
12641264
}
12651265
return $set_value;
1266-
} elsif (defined($ENV{"HOME"}) && (-r $ENV{"HOME"} . "/.lcovrc")) {
1267-
$config = read_config($ENV{"HOME"} . "/.lcovrc");
1268-
} elsif (-r "/etc/lcovrc") {
1269-
$config = read_config("/etc/lcovrc");
1270-
} elsif (-r "/usr/local/etc/lcovrc") {
1271-
$config = read_config("/usr/local/etc/lcovrc");
1266+
} elsif (exists($ENV{"HOME"}) &&
1267+
-r File::Spec->catfile($ENV{"HOME"}, '.lcovrc')) {
1268+
$config = read_config(File::Spec->catfile($ENV{"HOME"}, '.lcovrc'));
1269+
} elsif (exists($ENV{"LCOV_HOME"}) &&
1270+
-r File::Spec->catfile($ENV{"LCOV_HOME"}, 'etc', 'lcovrc')) {
1271+
$config = read_config(
1272+
File::Spec->catfile($ENV{"LCOV_HOME"}, 'etc', 'lcovrc'));
12721273
}
12731274

12741275
if ($config) {

man/lcovrc.5

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ code coverage tool (see
1313
.br
1414

1515
The system\-wide configuration file is located at
16-
.IR /etc/lcovrc .
16+
.IR $LCOV_HOME/etc/lcovrc .
17+
This is typically either
18+
.IR /etc/lcovrc
19+
or
20+
.IR /usr/local/etc/lcovrc
21+
but may be wherever you have installed the lcov package.
1722
To change settings for a single user, place a customized copy of this file at
1823
location
1924
.IR ~/.lcovrc .
@@ -2618,7 +2623,7 @@ Default is '0': case sensitive matching.
26182623
.SH FILES
26192624

26202625
.TP
2621-
.I /etc/lcovrc
2626+
.I $LCOV_HOME/etc/lcovrc
26222627
The system\-wide
26232628
.B lcov
26242629
configuration file.

0 commit comments

Comments
 (0)