How to skip/disable unit test cases while rustc testing using the package Cargo.toml file

I see the following tidy package's unit test failures when running rust tests:

python3 src/bootstrap/bootstrap.py test --exclude src/tools/tidy --no-fail-fast --bless --target x86_64-unknown-linux-gnu

I am executing rustc bootstrapping tests and these unit test fails.

I have exclude the tidy package via --exclude src/tools/tidy arg in the command but it still executes the tests. Is there any other way to disable tidy unit test cases?

Testing tidy (stage0 -> stage1, x86_64-unknown-linux-gnu) Compiling tidy v0.1.0 (/home/rust/src/tools/tidy) Finished release [optimized] target(s) in 15.14s

 Running unittests src/lib.rs (build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps/tidy-268e857e44aa5cf1)

uploaded "/home/rust/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps/tidy-268e857e44aa5cf1", waiting for result thread 'main' panicked at src/tools/remote-test-client/src/main.rs:310:9: client.read_exact(&mut header) failed with failed to fill whole buffer note: run with RUST_BACKTRACE=1 environment variable to display a backtrace error: test failed, to rerun pass --lib

 Running unittests src/main.rs (build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps/rust_tidy-f166db05696a5b67)

uploaded "/home/rust/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps/rust_tidy-f166db05696a5b67", waiting for result thread 'main' panicked at src/tools/remote-test-client/src/main.rs:310:9: client.read_exact(&mut header) failed with failed to fill whole buffer note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

error: test failed, to rerun pass --bin rust-tidy Build completed unsuccessfully in 0:17:28

I was trying to skip/disable those unit tests using Cargo.toml file in src/tools/tidy/Cargo.toml as mentioned below(bold lines added):

My Cargo.toml file with above mentioned changes is as follows:

[package] name = "tidy" version = "0.1.0" edition = "2021" autobins = false

[dependencies] cargo_metadata = "0.15" regex = "1" miropt-test-tools = { path = "../miropt-test-tools" } walkdir = "2" ignore = "0.4.18" semver = "1.0" termcolor = "1.1.3" rustc-hash = "1.1.0"

[[bin]] name = "rust-tidy" path = "src/main.rs" test = false

[lib] path = "src/lib.rs" test = false

Still I see the same failures. How to disable the unit tests of a package using Cargo.toml file. Please let me know if I am missing something or doing anything wrong.

Thanks.

I think you also need to pass --exclude tidyselftest

@ehuss, --exclude tidyselftest works! Thanks a lot for the help!

I would like to know a few things (out of curiosity),

  1. Why --exclude src/tools/tidy alone is not enough to exclude tidy unit tests and we need to pass --exclude tidyselftest also.

  2. I couldn't find any information on --exclude tidyselftest in rust book or doc. Can you help me understand it more better?

  3. Is there any similar way (with command line arg) to exclude/skip unit tests of other packages instead of using ignore tags (tried with `--exclude file path, but doesn't work)?

    For example in file compiler/rustc_errors/src/markdown/tests/term.rs, I can add the ignore tag as follows:

@@ -60,6 +60,7 @@  
  }

   #[test]  
 **+#[ignore]**  
  fn test_output() {  
      // Capture `--bless` when run via ./x   
      let bless = std::env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");

This works and ignores the unit tests. But, it's difficult to keep track of all files with ignore tags. Thus, I want to do it using command line arguments so that all ignored files are tracked.

  1. These tidy unit tests don't fail when testing on native host targets but do fail while cross-compiling on other targets. What can be the reason for this?

FYI use code blocks instead of block quotes:

```
preformatted text here
```

Because otherwise there wouldn't be a way to specify "run tidy" and "run tests of tidy itself". It can be helpful if you are working on tidy's self tests to be able to run them by themselves.

There isn't any documentation for each individual test target. The best thing available is the list via ./x test --help --verbose which will list all of them.

You can exclude an entire package with something like --exclude compiler/rustc_errors. Look at the list mentioned above for the names of things that can be selected.

I don't know what kind of cross-compiling you are doing, or what command you are running. AFAIK, tidyselftest does not support cross-compilation (it is hard-coded to run with the bootstrap build target).

Thanks for the prompt reply and answering my queries.

I don't know what kind of cross-compiling you are doing, or what command you are running. AFAIK, tidyselftest does not support cross-compilation (it is hard-coded to run with the bootstrap build target).

Sorry for the confusion here. I am using the same command as mentioned above and testing the bootstrap build target (which is different from my host machine).