是否可以在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
}
另见: