From 619cc9dca23ea49cafe8251b3ce84791031e6583 Mon Sep 17 00:00:00 2001 From: Andrew Hayzen Date: Mon, 27 Jan 2025 16:18:28 +0000 Subject: [PATCH] WIP: cov: ensure we use host llvm version and clear coverage data --- .github/workflows/github-cxx-qt-tests.yml | 6 ++++-- scripts/grcov_cxx_qt.sh | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-cxx-qt-tests.yml b/.github/workflows/github-cxx-qt-tests.yml index 4c77695dc..5e312068d 100644 --- a/.github/workflows/github-cxx-qt-tests.yml +++ b/.github/workflows/github-cxx-qt-tests.yml @@ -75,7 +75,9 @@ jobs: run: | rustup default 1.77.2 cargo install grcov - rustup component add llvm-tools rustfmt + rustup component add rustfmt + - run: test -d /usr/lib/llvm-18/bin/ + - run: rm -f coverage/*.profraw - name: build env: RUSTFLAGS: -Cinstrument-coverage @@ -87,7 +89,7 @@ jobs: LLVM_PROFILE_FILE: coverage/coverage_data-%p-%m.profraw run: cargo test --lib --package cxx-qt-gen - name: generate-report - run: grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/debug/lcov.info --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP + run: grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing --llvm --llvm-path /usr/lib/llvm-18/bin/ -o ./target/debug/lcov.info --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP - name: upload-report uses: codecov/codecov-action@v5 with: diff --git a/scripts/grcov_cxx_qt.sh b/scripts/grcov_cxx_qt.sh index 1103d872b..1c4ee6e9c 100755 --- a/scripts/grcov_cxx_qt.sh +++ b/scripts/grcov_cxx_qt.sh @@ -5,19 +5,30 @@ # # SPDX-License-Identifier: MIT OR Apache-2.0 -# Assumes you have grcov and llvm-tools +# Assumes you have grcov and llvm in a system path # Install: # cargo install grcov -# rustup component add llvm-tools + set -ex + # Ensure we are in the right directory SCRIPT=$(realpath "$0") SCRIPTPATH=$(dirname "$SCRIPT") cd "$SCRIPTPATH/../" +# Ensure coverage folder is cleared +rm -f "$SCRIPTPATH"/coverage/*.profraw + +# Check that the llvm path exists +# +# We can use rustup component add llvm-tools but this can be out of sync +if [ ! -d /usr/lib/llvm-18/bin/ ]; then + echo "LLVM path not found" +fi + export RUSTFLAGS="-Cinstrument-coverage" export LLVM_PROFILE_FILE="$SCRIPTPATH/coverage/coverage_data-%p-%m.profraw" cargo build --package cxx-qt-gen cargo test --package cxx-qt-gen -grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/ --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP -echo "Coverage html report generated in $(realpath "$SCRIPTPATH"/../target/debug/html)" \ No newline at end of file +grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --llvm --llvm-path=/usr/lib/llvm-18/bin/ -o ./target/debug/ --excl-start CODECOV_EXCLUDE_START --excl-stop CODECOV_EXCLUDE_STOP +echo "Coverage html report generated in $(realpath "$SCRIPTPATH"/../target/debug/html)"