【问题标题】:Rust disable all tests for specific targetRust 禁用特定目标的所有测试
【发布时间】:2020-09-04 10:15:43
【问题描述】:

我正在开发一个 Rust 板条箱,我想禁用一个特定目标架构 (wasm32) 的所有测试。我知道您可以使用 cfg 注释禁用特定源项:

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

但由于我想禁用所有测试,我想要一种更快的方法,最好是作为Cargo.toml 文件中的配置。箱子看起来像这样:

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

即我要禁用的测试存储在tests 目录中。

【问题讨论】:

    标签: testing rust target-platform


    【解决方案1】:

    如果您没有很多测试文件,那么您可以禁用将其应用于包含元素的整个模块:

    #![cfg(not(target_arch="wasm32"))]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-06
      相关资源
      最近更新 更多