Skip to content

Commit

Permalink
Rollup merge of rust-lang#131346 - jieyouxu:prune-invalid-directives,…
Browse files Browse the repository at this point in the history
… r=Zalathar

Restrict `ignore-mode-*` directives

This is only used by coverage test suites where the same sources get run under different coverage modes. Restrict `ignore-mode-<coverage_mode>` to only coverage modes.
  • Loading branch information
matthiaskrgr authored Oct 7, 2024
2 parents df61a0b + 64efbe2 commit 7d7b43c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
15 changes: 0 additions & 15 deletions src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-loongarch64",
"ignore-macabi",
"ignore-macos",
"ignore-mode-assembly",
"ignore-mode-codegen",
"ignore-mode-codegen-units",
"ignore-mode-coverage-map",
"ignore-mode-coverage-run",
"ignore-mode-crashes",
"ignore-mode-debuginfo",
"ignore-mode-incremental",
"ignore-mode-js-doc-test",
"ignore-mode-mir-opt",
"ignore-mode-pretty",
"ignore-mode-run-make",
"ignore-mode-run-pass-valgrind",
"ignore-mode-rustdoc",
"ignore-mode-rustdoc-json",
"ignore-mode-ui",
"ignore-mode-ui-fulldeps",
"ignore-msp430",
"ignore-msvc",
"ignore-musl",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/header/cfg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use crate::common::{CompareMode, Config, Debugger, Mode};
use crate::common::{CompareMode, Config, Debugger};
use crate::header::IgnoreDecision;

const EXTRA_ARCHS: &[&str] = &["spirv"];
Expand Down Expand Up @@ -222,7 +222,7 @@ pub(super) fn parse_cfg_name_directive<'a>(
name: format!("mode-{}", config.mode.to_str()),
allowed_names: ContainsPrefixed {
prefix: "mode-",
inner: Mode::STR_VARIANTS,
inner: ["coverage-run", "coverage-map"],
},
message: "when the test mode is {name}",
}
Expand Down
5 changes: 1 addition & 4 deletions src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::io::Read;
use std::path::Path;
use std::str::FromStr;

use super::iter_header;
use crate::common::{Config, Debugger, Mode};
Expand Down Expand Up @@ -574,14 +573,12 @@ fn families() {

#[test]
fn ignore_mode() {
for &mode in Mode::STR_VARIANTS {
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" };

assert_ne!(mode, other);
assert_eq!(config.mode, Mode::from_str(mode).unwrap());
assert_ne!(config.mode, Mode::from_str(other).unwrap());

assert!(check_ignore(&config, &format!("//@ ignore-mode-{mode}")));
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
Expand Down

0 comments on commit 7d7b43c

Please sign in to comment.