Skip to content

Commit f4b1cd2

Browse files
yaahcdconnolly
authored andcommitted
correctly specify all binaries
1 parent a930337 commit f4b1cd2

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

.github/workflows/coverage.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,43 @@ jobs:
1616
runs-on: ubuntu-20.04
1717
steps:
1818
- uses: actions/checkout@v2
19+
1920
- uses: actions-rs/toolchain@v1
2021
with:
2122
toolchain: nightly
2223
override: true
2324
profile: minimal
2425
components: llvm-tools-preview
26+
2527
- name: Install rustfilt symbol demangler
26-
run: cargo install rustfilt
28+
run: |
29+
cargo install rustfilt
30+
2731
- name: Rerun tests for coverage
28-
run: cargo test
2932
env:
30-
RUSTFLAGS: -Zinstrument-coverage
33+
RUSTFLAGS: -Zinstrument-coverage -C link-dead-code -C debuginfo=2
3134
LLVM_PROFILE_FILE: "${{ github.workspace }}/test.%p.profraw"
3235
ZEBRA_SKIP_NETWORK_TESTS: 1
36+
run: |
37+
cargo test
38+
cargo test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > filenames.txt
39+
3340
- name: Merge coverage data
34-
run: $(rustc --print target-libdir)/../bin/llvm-profdata merge --sparse test.*.profraw -o test.profdata
41+
run: |
42+
$(rustc --print target-libdir)/../bin/llvm-profdata merge test.*.profraw -o test.profdata
43+
3544
- name: Generate detailed html coverage report for github artifact
36-
run: $(rustc --print target-libdir)/../bin/llvm-cov show -format=html -ignore-filename-regex=".*/.cargo/registry/.*" -ignore-filename-regex=".*/.cargo/git/.*" -ignore-filename-regex=".*/.rustup/.*" -Xdemangler=rustfilt -show-instantiations -output-dir=./coverage -instr-profile=./test.profdata $(find target/debug/deps -type f -perm -u+x ! -name '*.so')
45+
run: |
46+
$(rustc --print target-libdir)/../bin/llvm-cov show -format=html -ignore-filename-regex=".*/.cargo/registry/.*" -ignore-filename-regex=".*/.cargo/git/.*" -ignore-filename-regex=".*/.rustup/.*" -Xdemangler=rustfilt -show-instantiations -output-dir=./coverage -instr-profile=./test.profdata $(printf -- "-object %s " $(cat filenames.txt))
47+
3748
- uses: actions/upload-artifact@v2
3849
with:
3950
name: coverage
4051
path: ./coverage
52+
4153
- name: Generate lcov coverage report for codecov
42-
run: $(rustc --print target-libdir)/../bin/llvm-cov export -format=lcov -instr-profile=test.profdata $(find target/debug/deps -type f -perm -u+x ! -name '*.so') > "lcov.info"
54+
run: |
55+
$(rustc --print target-libdir)/../bin/llvm-cov export -format=lcov -instr-profile=test.profdata $(printf -- "-object %s " $(cat filenames.txt)) > "lcov.info"
56+
4357
- name: Upload coverage report to Codecov
4458
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Cargo files
22
/target/
3+
/coverage-target/
34
# Firebase caches (?)
45
.firebase/
56
# Emacs detritus

zebra-utils/coverage

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
set -e
33
set -o xtrace
44

5-
rm -rf ./target/
6-
mkdir -p ./target/coverage
7-
ZEBRA_SKIP_NETWORK_TESTS=1 LLVM_PROFILE_FILE="${PWD}/target/coverage/test.%p.profraw" RUSTFLAGS="-Zinstrument-coverage" cargo test
8-
$(rustc --print target-libdir)/../bin/llvm-profdata merge --sparse ./target/coverage/test.*.profraw -o ./target/coverage/test.profdata
5+
export CARGO_TARGET_DIR="coverage-target"
96

10-
rm -rf ./target/coverage/html/
11-
# This one works and shows all the details I want in the CLI
12-
$(rustc --print target-libdir)/../bin/llvm-cov show \
7+
rm -rf ./"$CARGO_TARGET_DIR"/coverage
8+
mkdir -p ./$CARGO_TARGET_DIR/coverage
9+
export ZEBRA_SKIP_NETWORK_TESTS=1
10+
export LLVM_PROFILE_FILE="${PWD}/$CARGO_TARGET_DIR/coverage/test.%m.profraw"
11+
export RUSTFLAGS="-Zinstrument-coverage -C link-dead-code -C debuginfo=2"
12+
cargo +nightly test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > ./$CARGO_TARGET_DIR/files.txt
13+
cargo +nightly test
14+
$(rustc +nightly --print target-libdir)/../bin/llvm-profdata merge --sparse ./$CARGO_TARGET_DIR/coverage/test.*.profraw -o ./$CARGO_TARGET_DIR/coverage/test.profdata
15+
16+
rm -rf ./$CARGO_TARGET_DIR/coverage/html/
17+
18+
$(rustc +nightly --print target-libdir)/../bin/llvm-cov show \
1319
-format=html \
1420
-Xdemangler=rustfilt \
1521
-show-instantiations \
16-
-output-dir=./target/coverage/html \
22+
-output-dir=./$CARGO_TARGET_DIR/coverage/html \
1723
-ignore-filename-regex=".*/.cargo/registry/.*" \
1824
-ignore-filename-regex=".*/.cargo/git/.*" \
1925
-ignore-filename-regex=".*/.rustup/.*" \
20-
-instr-profile=./target/coverage/test.profdata \
21-
$(find target/ -type f -perm -u+x ! -name '*.so')
26+
-instr-profile=./$CARGO_TARGET_DIR/coverage/test.profdata \
27+
$(printf -- "-object %s " $(cat ./$CARGO_TARGET_DIR/files.txt))
2228

23-
xdg-open ./target/coverage/html/index.html
29+
xdg-open ./$CARGO_TARGET_DIR/coverage/html/index.html

0 commit comments

Comments
 (0)