Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*.orig
*.rej

# ignore IDE config
.idea/

# ignore autogenerated test files
/tests/**/*.log
/tests/**/*.counts
Expand Down
3 changes: 3 additions & 0 deletions bin/lcov
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ use lcovutil qw ($tool_name $tool_dir $lcov_version $lcov_url
@comments

$maxParallelism $maxMemory
load_lcovignore @lcovignore
);

# Directory containing gcov kernel files
Expand Down Expand Up @@ -329,6 +330,8 @@ our $exit_code = 0;

my $trace;

load_lcovignore();

eval {
# Check for requested functionality
if ($reset) {
Expand Down
30 changes: 30 additions & 0 deletions lib/lcovutil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ our @EXPORT_OK = qw($tool_name $tool_dir $lcov_version $lcov_url $VERSION

%tlaColor %tlaTextColor use_vanilla_color %pngChar %pngMap
%dark_palette %normal_palette parse_w3cdtf
load_lcovignore @lcovignore
);

our @ignore;
Expand Down Expand Up @@ -339,6 +340,7 @@ our $EXCL_LINE = 'LCOV_EXCL_LINE';
our $EXCL_BR_LINE = 'LCOV_EXCL_BR_LINE';
our $EXCL_EXCEPTION_LINE = 'LCOV_EXCL_EXCEPTION_BR_LINE';

our @lcovignore;
our @exclude_file_patterns;
our @include_file_patterns;
our %excluded_files;
Expand Down Expand Up @@ -477,6 +479,27 @@ sub set_tool_name($)
$tool_name = shift;
}

sub load_lcovignore {
my $ignore_file = ".lcovignore";
@lcovignore = ();
return unless -e $ignore_file;

my $fh;
unless (open($fh, "<", $ignore_file)) {
warn "Warning: Cannot open $ignore_file: $!";
return;
}
while (my $line = <$fh>) {
chomp $line;
next if $line =~ /^\s*#/; # ignore comments
next if $line =~ /^\s*$/; # ignore empty lines
$line =~ s/\./\\./g;
$line =~ s/\*/.*/g;
push @lcovignore, qr/$line/;
}
close($fh);
}

#
# system_no_output(mode, parameters)
#
Expand Down Expand Up @@ -6811,6 +6834,13 @@ sub skipCurrentFile
}

# check whether this file should be excluded or not...
foreach my $pattern (@lcovignore) {
if ($filename =~ /$pattern/) {
lcovutil::info(1, "exclude $filename: matches .lcovignore pattern '$pattern'\n");
return 1;
}
}

foreach my $p (@lcovutil::exclude_file_patterns) {
my $pattern = $p->[0];
if ($filename =~ $pattern) {
Expand Down