From c24d95c88522397162df69d7ba9616a017cae12f Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 5 Mar 2019 15:04:16 -0800 Subject: [PATCH] Remove bench-tps, upload-perf, and bench-streamer from code coverage report --- scripts/coverage.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 0412fcd1a..d6f794dc0 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -35,29 +35,31 @@ _ scripts/fetch-grcov.sh echo "--- grcov" ./grcov target/cov/debug/deps/ > target/cov/lcov-full.info -echo "--- filter-non-local-files-from-lcov" -# TODO: The grcov `-s` option could be used to replace this function once grcov -# doesn't panic on files with the same name in different directories of a -# repository -filter-non-local-files-from-lcov() { +echo "--- filter-files-from-lcov" + +# List of directories to remove from the coverage report +ignored_directories="^(bench-tps|upload-perf|bench-streamer)" + +filter-files-from-lcov() { declare skip=false while read -r line; do if [[ $line =~ ^SF:/ ]]; then skip=true # Skip all absolute paths as these are references into ~/.cargo elif [[ $line =~ ^SF:(.*) ]]; then - # Skip relative paths that don't exist declare file="${BASH_REMATCH[1]}" - if [[ -r $file ]]; then + if [[ $file =~ $ignored_directories ]]; then + skip=true # Skip paths into ignored locations + elif [[ -r $file ]]; then skip=false else - skip=true + skip=true # Skip relative paths that don't exist fi fi [[ $skip = true ]] || echo "$line" done } -filter-non-local-files-from-lcov < target/cov/lcov-full.info > target/cov/lcov.info +filter-files-from-lcov < target/cov/lcov-full.info > target/cov/lcov.info echo "--- html report" # ProTip: genhtml comes from |brew install lcov| or |apt-get install lcov|