-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.Category: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
I tried this test code with RUSTFLAGS="-Cpanic=abort -Zpanic_abort_tests"
:
#[test]
#[should_panic(expected = "new panic")]
fn resume_unwind_panics() {
std::panic::resume_unwind(Box::new("new panic"));
}
I expected to see this happen: The test result should be "ok".
Instead, this happened: The test fails:
failures:
---- err::tests::resume_unwind_panics stdout ----
---- err::tests::resume_unwind_panics stderr ----
Unexpected error: child process exited with signal 6
Meta
rustc --version --verbose
:
rustc 1.46.0-nightly (daecab3a7 2020-07-10)
binary: rustc
commit-hash: daecab3a784f28082df90cebb204998051f3557d
commit-date: 2020-07-10
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
Metadata
Metadata
Assignees
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.Category: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Status
Done
Milestone
Relationships
Development
Select code repository
Activity
davidhewitt commentedon Jul 13, 2020
I'd be happy to write a patch to resolve this, but I'd need some guidance first as to what a solution might entail. (cc @tmandry ?)
tmandry commentedon Jul 14, 2020
I don't think this is a bug, with the testing machinery at least. The same thing happens when this code is run outside a test in a binary with
-Cpanic=abort
: the process aborts (signal 6) with no information printed.resume_unwind
doesn't necessarily translate topanic
whenpanic=abort
, and there's no way to unwind. That said, a friendlier error message would be nice.davidhewitt commentedon Jul 14, 2020
That's a reasonable argument. That said, a test suite running with
panic=abort
can fail despite running fine withpanic=unwind
, so it would be desirable to have a way to resolve it.Perhaps a
#[cfg(not(panic="abort"))]
attribute would be a reasonable way to just remove problematic tests like this?tmandry commentedon Jul 15, 2020
panic=abort
changes the semantics of your program, so that's expected in some cases.I think that'd be reasonable, but as far as I know there isn't a conditional compilation flag for panic behavior (I believe there's an issue for this floating around somewhere). In Fuchsia we manually added a
--cfg
flag for it to our build. I'd support an effort to add a standard one.#[cfg(panic = '...')]
#74754Rollup merge of rust-lang#74754 - davidhewitt:cfg-panic, r=ecstatic-m…
Enselic commentedon Dec 12, 2023
Triage: Looks like this was resolved with #74754? I'll go ahead and close. Please re-open if I am mistaken.