Skip to content

Test suite ignores tests after an exit(0). #33954

Closed
@cristianoliveira

Description

@cristianoliveira

I was dealing with this issue (the tests that do not run) for while then I figured out that it was because of an exit(0) that was added in the middle of a method.

The problem occurs when there is some method that calls exit(0). The test suite starts to ignore fails for the next tests even for tests in others modules depending on the order of execution.

Example of erroneous code:

use std::process::exit;

fn main() {
    println!("Hello, world!");
}

fn die() { // name is just an example
    exit(0)
}

#[test]
fn it_works() {
    assert!(true);
}

#[test]
fn it_does_not_run() {
    assert!(false);
}

#[test]
#[should_panic]
fn it_dies() {
    die();
}

// another file.
mod other {
    #[test]
    fn it_may_run() {
        assert!(false);
    }
}

I hoped that the it_dies test does not run and the others tests run without the influence of this problematic one.

I got a strange behavior where the tests started to be ignored and the suite returning the total of all tests that supposed to be performed.

I know that dealing with exit(0) on the tests may be difficult but I hope that the test suite: runs all the tests, shows some error/warning or an option to wait for it, like #[should_exit].

Btw, you are doing a great job guys!

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