我有一个带几个板条箱的工作区。我需要排除一个特定的测试。
我尝试添加环境变量检查,但这不起作用。我想过cargo test滤掉环境变量。
// package1/src/lib.rs
// ...
#[cfg(test)]
mod tests {
#[test]
fn test1() {
if std::env::var("CI").is_ok() {
return;
}
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试--exclude使用各种选项传递参数,但它们都不起作用:
cargo test --workspace --exclude test1cargo test --workspace --exclude tests:test1cargo test --workspace --exclude tests::test1cargo test --workspace --exclude '*test1'cargo test --workspace --exclude 'tests*test1'cargo test --workspace --exclude package1
这将跳过包中的所有测试。cargo test --workspace --exclude 'package1*test1'如何运行除一个之外的所有工作区测试?