diff --git a/.gitignore b/.gitignore index 1fbea972..9acfea23 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ *.orig *.rej +# ignore IDE config +.idea/ + # ignore autogenerated test files /tests/**/*.log /tests/**/*.counts diff --git a/bin/lcov b/bin/lcov index 4e1fef23..cf381149 100755 --- a/bin/lcov +++ b/bin/lcov @@ -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 @@ -329,6 +330,8 @@ our $exit_code = 0; my $trace; +load_lcovignore(); + eval { # Check for requested functionality if ($reset) { diff --git a/lib/lcovutil.pm b/lib/lcovutil.pm index 97b8b3c9..9d3217d8 100644 --- a/lib/lcovutil.pm +++ b/lib/lcovutil.pm @@ -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; @@ -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; @@ -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) # @@ -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) {