Skip to content

Commit

Permalink
fix coverage.sh for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Feb 16, 2025
1 parent 6580ef5 commit c276427
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
components: llvm-tools-preview
toolchain: stable
rustflags: ""

- name: Install llvm-cov
env:
Expand Down
30 changes: 16 additions & 14 deletions tests/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# script to run project tests and report code coverage
# uses llvm-cov (https://github.com/taiki-e/cargo-llvm-cov)

LLVM_COV_OPTS=()
CARGO_TEST_OPTS=("--")
COV="cargo llvm-cov"
COV_OPTS="--html"
CARGO_TEST_OPTS=("--")

_die() {
echo "err $*"
Expand Down Expand Up @@ -41,10 +41,8 @@ while [ -n "$1" ]; do
shift
;;
--ci)
COV_CI="$COV --lcov --output-path coverage.lcov"
INDEXER=esplora $COV_CI
INDEXER=electrum $COV_CI --no-clean
exit 0
COV_OPTS="--lcov --output-path coverage.lcov"
CI=1
;;
*)
help
Expand All @@ -54,15 +52,19 @@ while [ -n "$1" ]; do
shift
done

_tit "installing requirements"
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov
if [ -z "$CI" ]; then
_tit "installing requirements"
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov
fi

_tit "generating coverage report"
# shellcheck disable=2086
INDEXER=esplora $COV --html "${LLVM_COV_OPTS[@]}" "${CARGO_TEST_OPTS[@]}"
INDEXER=electrum $COV --no-clean --html "${LLVM_COV_OPTS[@]}" "${CARGO_TEST_OPTS[@]}"
SKIP_INIT=1 INDEXER=electrum $COV --no-clean --html "${LLVM_COV_OPTS[@]}" --features altered
INDEXER=electrum $COV $COV_OPTS "${CARGO_TEST_OPTS[@]}"
INDEXER=esplora $COV $COV_OPTS --no-clean "${CARGO_TEST_OPTS[@]}"
SKIP_INIT=1 INDEXER=esplora $COV $COV_OPTS --no-clean --features altered "${CARGO_TEST_OPTS[@]}"

## show html report location
echo "generated html report: target/llvm-cov/html/index.html"
if [ -z "$CI" ]; then
## show html report location
echo "generated html report: target/llvm-cov/html/index.html"
fi
2 changes: 1 addition & 1 deletion tests/start_services.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
set -u

_die () {
echo "ERR: $*" >&2
Expand Down

0 comments on commit c276427

Please sign in to comment.