lundi 22 mars 2021

Run `cargo test --workspace` and exclude one test

I have a workspace with several crates. I need to exclude a particular test.

I tried adding an environment variable check, but this doesn't work. I guess cargo test filters out the environment variables.

// package1/src/lib.rs

// ...

#[cfg(test)]
mod tests {

    #[test]
    fn test1() {
        if std::env::var("CI").is_ok() {
            return;
        }
        // ...
    }
}

Then I tried passing the --exclude parameter with various options, but none of them work:

  • 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 This skips all of the tests in the package.
  • cargo test --workspace --exclude 'package1*test1'

How can I run all workspace tests except one?

Aucun commentaire:

Enregistrer un commentaire