我有一个带有多个板条箱的工作空间。 我需要排除特定的测试。
我尝试添加环境变量检查,但这并不起作用。 我猜过滤掉了环境变量。
然后我尝试使用不同的选项传递
我尝试添加环境变量检查,但这并不起作用。 我猜过滤掉了环境变量。
// package1/src/lib.rs
// ...
#[cfg(test)]
mod tests {
#[test]
fn test1() {
if std::env::var("CI").is_ok() {
return;
}
// ...
}
}
然后我尝试使用不同的选项传递
--exclude
参数,但它们都无效:
cargo test --workspace --exclude test1
cargo test --workspace --exclude tests:test1
cargo test --workspace --exclude tests::test1
cargo test --workspace --exclude '*test1'
cargo test --workspace --exclude 'tests*test1'
cargo test --workspace --exclude package1
这会跳过包中的所有测试。cargo test --workspace --exclude 'package1*test1'
-- --skip
参数中指定包或者板条箱的名称? - M. Leonhardcargo test --workspace -- --skip FILTER
可以完美地工作。 - Cyrill