Skip to content

Running cargo miri test fails due to thread outliving main thread #81

@StoicDeveloper

Description

@StoicDeveloper

With the minimal example:

#[cfg(test)]
pub mod tests {
  
    #[test]
    fn mf_test_delay() {
        block_on(Delay::new(Duration::from_millis(500)));
    }
}

running the command:

MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test mf_  

will cause the tests to pass, but the overall command will fail with the following output:

❯ MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test mf_
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running unittests src/lib.rs (<location>)

running 1 tests
test stream::futures_unordered::mapped_futures::tests::mf_test_delay ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.68s

error: the main thread terminated without waiting for all remaining threads

note: set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check

error: aborting due to 1 previous error

error: test failed, to rerun pass `--lib`

Rust version:
❯ rustc --version
rustc 1.85.0-nightly (0aeaa5eb2 2024-12-14)

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