From 141131f3a62f8b85314e5c70985f98d9321ba155 Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Mon, 23 Dec 2019 16:32:29 +0900 Subject: [PATCH] Stabilize fn coverage by creating a clean room (#7576) * Stabilize fn coverage by pruning all updated files * Pruning didn't work; Switch to clean room dir * Oh, shellcheck... * Remove the data_dir variable * Comment about relationale for find + while read --- scripts/coverage.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 1063d6198..7a0df653a 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -31,9 +31,12 @@ export RUST_MIN_STACK=8388608 echo "--- remove old coverage results" if [[ -d target/cov ]]; then - find target/cov -name \*.gcda -print0 | xargs -0 rm -f + find target/cov -name \*.gcda -delete fi rm -rf target/cov/$reportName +mkdir -p target/cov +timing_file=target/cov/before-test +touch "$timing_file" source ci/rust-version.sh nightly @@ -42,7 +45,20 @@ RUST_LOG=solana=trace _ cargo +$rust_nightly test --target-dir target/cov "${pac echo "--- grcov" -_ grcov target/cov/debug/deps/ > target/cov/lcov-full.info +# Create a clean room dir only with updated gcda/gcno files for this run +rm -rf target/cov/tmp +mkdir -p target/cov/tmp + +# Can't use a simpler construct under the condition of SC2044 and bash 3 +# (macOS's default). See: https://github.com/koalaman/shellcheck/wiki/SC2044 +find target/cov -name \*.gcda -newer "$timing_file" -print0 | + (while IFS= read -r -d '' gcda_file; do + gcno_file="${gcda_file%.gcda}.gcno" + ln -s "../../../$gcda_file" "target/cov/tmp/$(basename "$gcda_file")" + ln -s "../../../$gcno_file" "target/cov/tmp/$(basename "$gcno_file")" + done) + +_ grcov target/cov/tmp > target/cov/lcov-full.info echo "--- filter-files-from-lcov"