[][src]Macro rusty_fork::rusty_fork_test

macro_rules! rusty_fork_test {
    (#![rusty_fork(timeout_ms = $timeout:expr)]
     $(
         $(#[$meta:meta])*
         fn $test_name:ident() $body:block
    )*) => { ... };
    ($(
         $(#[$meta:meta])*
         fn $test_name:ident() $body:block
    )*) => { ... };
}

Run Rust tests in subprocesses.

The basic usage is to simply put this macro around your #[test] functions.

#[macro_use] extern crate rusty_fork;

rusty_fork_test! {
    #[test]
    fn my_test() {
        assert_eq!(2, 1 + 1);
    }

    // more tests...
}

Each test will be run in its own process. If the subprocess exits unsuccessfully for any reason, including due to signals, the test fails.

It is also possible to specify a timeout which is applied to all tests in the block, like so:

#[macro_use] extern crate rusty_fork;

rusty_fork_test! {
    #![rusty_fork(timeout_ms = 1000)]
    #[test]
    fn my_test() {
        do_some_expensive_computation();
    }

    // more tests...
}

If any individual test takes more than the given timeout, the child is terminated and the test panics.

Using the timeout feature requires the timeout feature for this crate to be enabled (which it is by default).