Simplify the directives for ignoring coverage-test modes

This commit is contained in:
Zalathar 2024-10-08 19:08:54 +11:00
parent cf24c73141
commit 27583378d3
8 changed files with 18 additions and 23 deletions

View File

@ -42,6 +42,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-cdb",
"ignore-compare-mode-next-solver",
"ignore-compare-mode-polonius",
"ignore-coverage-map",
"ignore-coverage-run",
"ignore-cross-compile",
"ignore-debug",
"ignore-eabi",
@ -64,8 +66,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-loongarch64",
"ignore-macabi",
"ignore-macos",
"ignore-mode-coverage-map",
"ignore-mode-coverage-run",
"ignore-msp430",
"ignore-msvc",
"ignore-musl",

View File

@ -217,13 +217,10 @@ pub(super) fn parse_cfg_name_directive<'a>(
}
// Coverage tests run the same test file in multiple modes.
// If a particular test should not be run in one of the modes, ignore it
// with "ignore-mode-coverage-map" or "ignore-mode-coverage-run".
// with "ignore-coverage-map" or "ignore-coverage-run".
condition! {
name: format!("mode-{}", config.mode.to_str()),
allowed_names: ContainsPrefixed {
prefix: "mode-",
inner: ["coverage-run", "coverage-map"],
},
name: config.mode.to_str(),
allowed_names: ["coverage-map", "coverage-run"],
message: "when the test mode is {name}",
}

View File

@ -572,17 +572,15 @@ fn families() {
}
#[test]
fn ignore_mode() {
for mode in ["coverage-map", "coverage-run"] {
// Indicate profiler support so that "coverage-run" tests aren't skipped.
let config: Config = cfg().mode(mode).profiler_support(true).build();
let other = if mode == "coverage-run" { "coverage-map" } else { "coverage-run" };
fn ignore_coverage() {
// Indicate profiler support so that "coverage-run" tests aren't skipped.
let config = cfg().mode("coverage-map").profiler_support(true).build();
assert!(check_ignore(&config, "//@ ignore-coverage-map"));
assert!(!check_ignore(&config, "//@ ignore-coverage-run"));
assert_ne!(mode, other);
assert!(check_ignore(&config, &format!("//@ ignore-mode-{mode}")));
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
}
let config = cfg().mode("coverage-run").profiler_support(true).build();
assert!(!check_ignore(&config, "//@ ignore-coverage-map"));
assert!(check_ignore(&config, "//@ ignore-coverage-run"));
}
#[test]

View File

@ -1,5 +1,5 @@
LL| |//@ edition: 2021
LL| |//@ ignore-mode-coverage-map
LL| |//@ ignore-coverage-map
LL| |//@ ignore-windows
LL| |//@ llvm-cov-flags: --use-color
LL| |

View File

@ -1,5 +1,5 @@
//@ edition: 2021
//@ ignore-mode-coverage-map
//@ ignore-coverage-map
//@ ignore-windows
//@ llvm-cov-flags: --use-color

View File

@ -1,4 +1,4 @@
LL| |//@ ignore-mode-coverage-map
LL| |//@ ignore-coverage-map
LL| |
LL| 1|fn main() {}

View File

@ -1,3 +1,3 @@
//@ ignore-mode-coverage-map
//@ ignore-coverage-map
fn main() {}

View File

@ -1,3 +1,3 @@
//@ ignore-mode-coverage-run
//@ ignore-coverage-run
fn main() {}