Skip to content

Commit

Permalink
Merge pull request #909 from PyO3/fix-grcov
Browse files Browse the repository at this point in the history
Use -Cpanic=abort for correct coverage
  • Loading branch information
kngwyu authored May 6, 2020
2 parents 626268d + 11c1c5e commit eb60a1c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ install:
- pip install setuptools-rust pytest pytest-benchmark tox

script:
- if ! [[ $FEATURES == *"pypy"* ]]; then export CARGO_INCREMENTAL=0; fi
# Options for grcov
- if ! [[ $FEATURES == *"pypy"* ]]; then export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off"; fi
- ./ci/travis/test.sh

deploy:
Expand Down
5 changes: 5 additions & 0 deletions ci/travis/cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ if [[ $FEATURES == *"pypy"* ]]; then
fi

### Run grcov ##################################################################
# export env vars and re-run tests
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zpanic_abort_tests -Zprofile -Cpanic=abort -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off"
export RUSTDOCFLAGS="-Cpanic=abort"
cargo test --features "$FEATURES num-bigint num-complex"

zip -0 ccov.zip `find . \( -name "pyo3*.gc*" \) -print`;
./grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o lcov.info;
Expand Down
8 changes: 8 additions & 0 deletions src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ mod tests {

#[test]
fn fetching_panic_exception_panics() {
// If -Cpanic=abort is specified, we can't catch panic.
if option_env!("RUSTFLAGS")
.map(|s| s.contains("-Cpanic=abort"))
.unwrap_or(false)
{
return;
}

let gil = Python::acquire_gil();
let py = gil.python();
let err: PyErr = PanicException::py_err("new panic");
Expand Down

0 comments on commit eb60a1c

Please sign in to comment.