Reputation: 179
Im trying to get a code coverage report following the below steps.
I want the generated files to be removed from the report. i treid..
lcov --remove coverage/lcov.info \ 'lib/*/*.freezed.dart' \ -o coverage/lcov.info
But this does nothing. Still shows the report with generated files. I don't know whether if i'm doing this the right way.
Upvotes: 1
Views: 1392
Reputation: 1
You can use a shell script to dynamically generate a list of files to exclude, based on their file extension, and then pass that list to lcov
using the --remove
option. Here's how you could do it for excluding .g.dart
files:
# Build an array of exclude patterns
exclude_patterns=()
while IFS= read -r pattern; do
exclude_patterns+=("$pattern")
done < <(find . -name "*.g.dart" | sed 's|^\./||')
# Now use the array when invoking lcov
lcov --remove lcov.info "${exclude_patterns[@]}" -o lcov_filtered.info
Explanation:
exclude_patterns
to hold the list of files to exclude.while
loop to read each line of output from the find
command, which searches for all files ending in .g.dart
in the current directory and its subdirectories.sed
command is used to remove the ./
prefix from the paths returned by find
.exclude_patterns
array.lcov
with the --remove
option, passing the exclude_patterns
array to specify the files to exclude. The -o
option specifies the output file for the filtered lcov report.Now, when you run this script, lcov
will generate a report that excludes all .g.dart
files.
Upvotes: 0