Attribute Macro lock

Source
#[lock]
Expand description

Run test case one by one when the lock is acquired It will automatically implement a file lock for the test case to prevent it run in the same time. Also, you can pass the second parameter to specific the waiting seconds, default will be 60 seconds.

#[cfg(test)]
mod tests {

    // `LOCK` is file based lock to prevent test1 an test2 run at the same time
    #[test_with::lock(LOCK)]
    #[test]
    fn test_1() {
        assert!(true);
    }

    // `LOCK` is file based lock to prevent test1 an test2 run at the same time
    #[test_with::lock(LOCK)]
    #[test]
    fn test_2() {
        assert!(true);
    }

    // `ANOTHER_LOCK` is file based lock to prevent test3 an test4 run at the same time with 3 sec
    // waiting time.
    #[test_with::lock(ANOTHER_LOCK, 3)]
    fn test_3() {
        assert!(true);
    }

    // `ANOTHER_LOCK` is file based lock to prevent test3 an test4 run at the same time with 3 sec
    // waiting time.
    #[test_with::lock(ANOTHER_LOCK, 3)]
    fn test_4() {
        assert!(true);
    }

}