diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 2e3c1ec48ee..98b27a5c6b6 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -409,6 +409,7 @@ pub struct TargetCfgs { pub all_targets: HashSet, pub all_archs: HashSet, pub all_oses: HashSet, + pub all_oses_and_envs: HashSet, pub all_envs: HashSet, pub all_abis: HashSet, pub all_families: HashSet, @@ -433,6 +434,7 @@ fn new(config: &Config) -> TargetCfgs { let mut all_targets = HashSet::new(); let mut all_archs = HashSet::new(); let mut all_oses = HashSet::new(); + let mut all_oses_and_envs = HashSet::new(); let mut all_envs = HashSet::new(); let mut all_abis = HashSet::new(); let mut all_families = HashSet::new(); @@ -441,6 +443,7 @@ fn new(config: &Config) -> TargetCfgs { for (target, cfg) in targets.into_iter() { all_archs.insert(cfg.arch.clone()); all_oses.insert(cfg.os.clone()); + all_oses_and_envs.insert(cfg.os_and_env()); all_envs.insert(cfg.env.clone()); all_abis.insert(cfg.abi.clone()); for family in &cfg.families { @@ -459,6 +462,7 @@ fn new(config: &Config) -> TargetCfgs { all_targets, all_archs, all_oses, + all_oses_and_envs, all_envs, all_abis, all_families, @@ -506,6 +510,12 @@ pub struct TargetCfg { panic: PanicStrategy, } +impl TargetCfg { + pub(crate) fn os_and_env(&self) -> String { + format!("{}-{}", self.os, self.env) + } +} + fn default_os() -> String { "none".into() } diff --git a/src/tools/compiletest/src/header/cfg.rs b/src/tools/compiletest/src/header/cfg.rs index da4af98ce91..3b9333dfe7a 100644 --- a/src/tools/compiletest/src/header/cfg.rs +++ b/src/tools/compiletest/src/header/cfg.rs @@ -84,6 +84,11 @@ macro_rules! condition { allowed_names: &target_cfgs.all_envs, message: "when the target environment is {name}" } + condition! { + name: &target_cfg.os_and_env(), + allowed_names: &target_cfgs.all_oses_and_envs, + message: "when the operative system and target environment are {name}" + } condition! { name: &target_cfg.abi, allowed_names: &target_cfgs.all_abis,