diff options
| author | Eric Huss <eric@huss.org> | 2022-08-07 21:44:23 -0700 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2022-08-07 23:32:27 -0700 |
| commit | c86e523d97104d508b98747079f12edd3b53a672 (patch) | |
| tree | f597c4edfb1e630659e75c7d72c8a623a4322979 | |
| parent | fab899640002eb67d9b55156f447bd435f959568 (diff) | |
| download | rust-c86e523d97104d508b98747079f12edd3b53a672.tar.gz rust-c86e523d97104d508b98747079f12edd3b53a672.zip | |
compiletest: match ignores on target family
This primarily is so that `ignore-wasm` works as expected (ignores all wasm-like targets).
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 8 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 1 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/tests.rs | 20 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 470bcc6551f..6f17b9e1be9 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -411,6 +411,10 @@ impl Config { self.target_cfg().abi == abi } + pub fn matches_family(&self, family: &str) -> bool { + self.target_cfg().families.iter().any(|f| f == family) + } + pub fn is_big_endian(&self) -> bool { self.target_cfg().endian == Endian::Big } @@ -436,6 +440,7 @@ pub struct TargetCfg { os: String, env: String, abi: String, + families: Vec<String>, pointer_width: u32, endian: Endian, } @@ -470,6 +475,7 @@ impl TargetCfg { let mut os = None; let mut env = None; let mut abi = None; + let mut families = Vec::new(); let mut pointer_width = None; let mut endian = None; for line in print_cfg.lines() { @@ -480,6 +486,7 @@ impl TargetCfg { "target_os" => os = Some(value), "target_env" => env = Some(value), "target_abi" => abi = Some(value), + "target_family" => families.push(value.to_string()), "target_pointer_width" => pointer_width = Some(value.parse().unwrap()), "target_endian" => { endian = Some(match value { @@ -497,6 +504,7 @@ impl TargetCfg { os: os.unwrap().to_string(), env: env.unwrap().to_string(), abi: abi.unwrap().to_string(), + families, pointer_width: pointer_width.unwrap(), endian: endian.unwrap(), } diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index c50dd3cc09d..8f097f47b45 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -682,6 +682,7 @@ impl Config { self.matches_os(name) || self.matches_env(name) || self.matches_abi(name) || + self.matches_family(name) || self.target.ends_with(name) || // target and env self.matches_arch(name) || matches_wasm32_alias() || diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 21523cc13e6..6c0e8f2e46f 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -421,3 +421,23 @@ fn wasm_special() { ); } } + +#[test] +fn families() { + let families = [ + ("x86_64-unknown-linux-gnu", "unix"), + ("x86_64-pc-windows-gnu", "windows"), + ("wasm32-unknown-unknown", "wasm"), + ("wasm32-unknown-emscripten", "wasm"), + ("wasm32-unknown-emscripten", "unix"), + ]; + for (target, family) in families { + let mut config = config(); + config.target = target.to_string(); + assert!(config.matches_family(family)); + let other = if family == "windows" { "unix" } else { "windows" }; + assert!(!config.matches_family(other)); + assert!(check_ignore(&config, &format!("// ignore-{family}"))); + assert!(!check_ignore(&config, &format!("// ignore-{other}"))); + } +} |
