【发布时间】:2018-03-31 22:58:53
【问题描述】:
我正在写一个测试:
#[cfg(test)]
mod tests {
#[test]
fn test_something() {
//content of test function
}
}
是否可以让这个测试在使用 Windows 时不运行而只在 Linux 上运行?
【问题讨论】:
标签: rust
我正在写一个测试:
#[cfg(test)]
mod tests {
#[test]
fn test_something() {
//content of test function
}
}
是否可以让这个测试在使用 Windows 时不运行而只在 Linux 上运行?
【问题讨论】:
标签: rust
您可以选择根本不编译测试
#[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
}
另见:
【讨论】: