Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以在Rust中编写测试,使其不在特定的操作系统上运行?_Rust - Fatal编程技术网

是否可以在Rust中编写测试,使其不在特定的操作系统上运行?

是否可以在Rust中编写测试,使其不在特定的操作系统上运行?,rust,Rust,我正在写一个测试: #[cfg(test)] mod tests { #[test] fn test_something() { //content of test function } } 是否可以在使用Windows时不运行此测试,而只在Linux上运行?您可以选择根本不编译此测试 #[cfg(not(target_os = "windows"))] #[test] fn test_something() { //content of tes

我正在写一个测试:

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

是否可以在使用Windows时不运行此测试,而只在Linux上运行?

您可以选择根本不编译此测试

#[cfg(not(target_os = "windows"))]
#[test]
fn test_something() {
    //content of test function
}
或者您可以选择编译它,但不运行它:

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