Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rust disable all tests for specific target

I am working on a Rust crate and I would like to disable all tests for one specific target architecture (wasm32). I know you can disable specific source items using a cfg annotation:

#[cfg(not(target_arch="wasm32"))]
#[test]
fn only_compile_on_not_wasm32() {
    ...
}

But as I want to disable all tests, I would like a quicker way, preferably as a configuration in the Cargo.toml file. The crate looks like this:

├── Cargo.toml
├── src
│   ├── ...
│   └── lib.rs
└── tests
    ├── ...
    └── mod.rs

i.e. the tests I want to disable are stored in the tests directory.

like image 883
stimulate Avatar asked Mar 10 '26 01:03

stimulate


1 Answers

If you don't have many test files, then you may disable entire modules applying it to the containing element:

#![cfg(not(target_arch="wasm32"))]
like image 111
Acorn Avatar answered Mar 13 '26 01:03

Acorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!