4

I am writing a test:

#[cfg(test)]
mod tests {
    #[test]
    fn test_something() {
        //content of test function
    }
}

Is it possible to make this test not run when using Windows and only run on Linux?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
ka s
  • 73
  • 1
  • 7

1 Answers1

7

You can choose to not compile the test at all

#[cfg(not(target_os = "windows"))]
#[test]
fn test_something() {
    //content of test function
}

Or you can choose to compile it but not run it:

#[test]
#[cfg_attr(target_os = "windows", ignore)]
fn test_something() {
    //content of test function
}

See also:

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366