From 11c1c5e6a1ae085371c503430294308e589d19a0 Mon Sep 17 00:00:00 2001 From: kngwyu Date: Wed, 6 May 2020 17:43:11 +0900 Subject: [PATCH] Use -Cpanic=abort for correct coverage --- .travis.yml | 3 --- ci/travis/cover.sh | 5 +++++ src/err.rs | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8319bfd452f..9bc12788012 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/ci/travis/cover.sh b/ci/travis/cover.sh index 87d1f13968a..0631f71afe9 100755 --- a/ci/travis/cover.sh +++ b/ci/travis/cover.sh @@ -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; diff --git a/src/err.rs b/src/err.rs index cb0ad2ee086..b93ff8ab55b 100644 --- a/src/err.rs +++ b/src/err.rs @@ -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");