Skip to content

miri test and #[should_panic] #636

Closed
@memoryruins

Description

@memoryruins

I've been running miri on various crates, including foundational ones on crates.io.
Currently, running cargo +nightly miri test on a test that is expected to panic, e.g.

#[should_panic]
#[test]
fn f() {
    panic!();
}

causes miri to stop the tests early and printing the following (in addition to a sizeable trace)

error[E0080]: constant evaluation error: the evaluated program panicked at 'explicit panic', src/main.rs:9:5
 --> src/main.rs:9:5
  |
9 |     panic!();
  |     ^^^^^^^^^ the evaluated program panicked at 'explicit panic', src/main.rs:9:5
  |
note: inside call to `f` at src/main.rs:8:1
 --> src/main.rs:8:1
  |
8 | / fn f() {
9 | |     panic!();
10| | }
  | |_^

It would be convenient if miri took account of the #[should_panic] attribute, allowing miri to continue on with other tests. It's trivial to add #[cfg(not(miri))], but the tests continuing to run might be expected by new users of miri.

If the current behaviour is expected or if the attribute is out of reach of miri, feel free to close ^^

miri 0.1.0 (3b83466 2019-02-15)
rustc 1.34.0-nightly (a9410cd1a 2019-02-15)
cargo 1.34.0-nightly (865cb7010 2019-02-10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions