Skip to content

Commit 7eb3aa3

Browse files
authored
Merge pull request #1545 from davidhewitt/instrument-coverage
coverage: use source-based coverage
2 parents 1aeaa13 + dafbec7 commit 7eb3aa3

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,39 @@ jobs:
169169
runs-on: ubuntu-latest
170170
steps:
171171
- uses: actions/checkout@v2
172+
- uses: actions/cache@v2
173+
with:
174+
path: |
175+
~/.cargo/registry
176+
~/.cargo/git
177+
target
178+
key: coverage-cargo-${{ hashFiles('**/Cargo.toml') }}
179+
- name: install grcov
180+
run: |
181+
wget https://github.com/mozilla/grcov/releases/download/v${GRCOV_VERSION}/grcov-linux-x86_64.tar.bz2 -qO- | tar -xjvf -
182+
mv grcov ~/.cargo/bin
183+
env:
184+
GRCOV_VERSION: 0.7.1
172185
- uses: actions-rs/toolchain@v1
173186
with:
174187
toolchain: nightly
175188
override: true
176189
profile: minimal
177-
- run: cargo test --no-default-features --no-fail-fast
178-
- run: cargo test --no-default-features --no-fail-fast --features "macros num-bigint num-complex hashbrown serde multiple-pymethods"
179-
- uses: actions-rs/[email protected]
180-
id: coverage
190+
components: llvm-tools-preview
191+
- run: LLVM_PROFILE_FILE="coverage-%p-%m.profraw" cargo test --no-default-features --no-fail-fast
192+
- run: LLVM_PROFILE_FILE="coverage-features-%p-%m.profraw" cargo test --no-default-features --no-fail-fast --features "macros num-bigint num-complex hashbrown serde multiple-pymethods"
193+
# can't yet use actions-rs/grcov with source-based coverage: https://github.com/actions-rs/grcov/issues/105
194+
# - uses: actions-rs/[email protected]
195+
# id: coverage
196+
# - uses: codecov/codecov-action@v1
197+
# with:
198+
# file: ${{ steps.coverage.outputs.report }}
199+
- run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing -o coverage.lcov
181200
- uses: codecov/codecov-action@v1
182201
with:
183-
file: ${{ steps.coverage.outputs.report }}
202+
file: coverage.lcov
203+
184204
env:
185205
CARGO_TERM_VERBOSE: true
186-
CARGO_INCREMENTAL: 0
187-
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
188-
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
206+
RUSTFLAGS: "-Zinstrument-coverage"
207+
RUSTDOCFLAGS: "-Zinstrument-coverage"

src/err/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,6 @@ mod tests {
557557
#[test]
558558
#[should_panic(expected = "new panic")]
559559
fn fetching_panic_exception_resumes_unwind() {
560-
// TODO replace with #[cfg(panic = "unwind")] once stable
561-
if !crate::cfg_panic_unwind() {
562-
// panic to meet the expected abort in panic=abort :-/
563-
panic!("new panic");
564-
}
565-
566560
use crate::panic::PanicException;
567561

568562
let gil = Python::acquire_gil();

src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,3 @@ pub mod doc_test {
425425
doctest!("guide/src/trait_bounds.md", guide_trait_bounds_md);
426426
doctest!("guide/src/types.md", guide_types_md);
427427
}
428-
429-
// interim helper until #[cfg(panic = ...)] is stable
430-
#[cfg(test)]
431-
fn cfg_panic_unwind() -> bool {
432-
option_env!("RUSTFLAGS").map_or(true, |var| !var.contains("-Cpanic=abort"))
433-
}

src/python.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,6 @@ mod test {
695695

696696
#[test]
697697
fn test_allow_threads_panics_safely() {
698-
// TODO replace with #[cfg(panic = "unwind")] once stable
699-
if !crate::cfg_panic_unwind() {
700-
return;
701-
}
702-
703698
let gil = Python::acquire_gil();
704699
let py = gil.python();
705700

0 commit comments

Comments
 (0)