compiletest: add specific //@ ignore-auxiliary for test support files

This is for files that *participate* in actual tests but should not be
built by `compiletest` (i.e. these files are involved through `mod xxx;`
or `include!()` or `#[path = "xxx"]`, etc.).

A specialized directive like `//@ ignore-auxiliary` makes it way easier
to audit disabled tests via `//@ ignore-test`.
This commit is contained in:
Jieyou Xu 2025-04-17 16:54:07 +08:00
parent 79a272c640
commit d20f848478
No known key found for this signature in database
GPG key ID: 045B995028EA6AFC
3 changed files with 11 additions and 0 deletions

View file

@ -44,6 +44,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-arm-unknown-linux-gnueabihf",
"ignore-arm-unknown-linux-musleabi",
"ignore-arm-unknown-linux-musleabihf",
"ignore-auxiliary",
"ignore-avr",
"ignore-beta",
"ignore-cdb",

View file

@ -100,6 +100,10 @@ fn parse_cfg_name_directive<'a>(
name: "test",
message: "always"
}
condition! {
name: "auxiliary",
message: "used by another main test file"
}
condition! {
name: &config.target,
allowed_names: &target_cfgs.all_targets,

View file

@ -940,3 +940,9 @@ fn test_supported_crate_types() {
"//@ needs-crate-type: bin, cdylib, dylib, lib, proc-macro, rlib, staticlib"
));
}
#[test]
fn test_ignore_auxiliary() {
let config = cfg().build();
assert!(check_ignore(&config, "//@ ignore-auxiliary"));
}