From 18712e6edf685855ce0e0470730192165e56e0b1 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 6 Jul 2017 11:25:29 +0800 Subject: [PATCH] compiletest: Refactor: Move the `ignore-{}` logic into its own method. Prepare for `normalize-std???` which will share the same logic. Added `ignore-32bit` and `ignore-64bit`. --- src/test/run-pass/i128-ffi.rs | 7 +--- src/tools/compiletest/src/header.rs | 56 ++++++++++++++--------------- src/tools/compiletest/src/util.rs | 8 +++++ 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/test/run-pass/i128-ffi.rs b/src/test/run-pass/i128-ffi.rs index d07fb7b4a71..d989210dd71 100644 --- a/src/test/run-pass/i128-ffi.rs +++ b/src/test/run-pass/i128-ffi.rs @@ -13,12 +13,7 @@ // should look like. // ignore-windows - -// Ignore 32 bit targets: -// ignore-x86 -// ignore-arm - -// ignore-emscripten +// ignore-32bit #![feature(i128_type)] diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 5ac60d8f2c8..59d08ceae21 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -40,15 +40,8 @@ impl EarlyProps { None, &mut |ln| { props.ignore = - props.ignore || config.parse_name_directive(ln, "ignore-test") || - config.parse_name_directive(ln, &ignore_target(config)) || - config.parse_name_directive(ln, &ignore_architecture(config)) || - config.parse_name_directive(ln, &ignore_stage(config)) || - config.parse_name_directive(ln, &ignore_env(config)) || - (config.mode == common::Pretty && - config.parse_name_directive(ln, "ignore-pretty")) || - (config.target != config.host && - config.parse_name_directive(ln, "ignore-cross-compile")) || + props.ignore || + config.parse_cfg_name_directive(ln, "ignore") || ignore_gdb(config, ln) || ignore_lldb(config, ln) || ignore_llvm(config, ln); @@ -62,28 +55,11 @@ impl EarlyProps { return props; - fn ignore_target(config: &Config) -> String { - format!("ignore-{}", util::get_os(&config.target)) - } - fn ignore_architecture(config: &Config) -> String { - format!("ignore-{}", util::get_arch(&config.target)) - } - fn ignore_stage(config: &Config) -> String { - format!("ignore-{}", config.stage_id.split('-').next().unwrap()) - } - fn ignore_env(config: &Config) -> String { - format!("ignore-{}", - util::get_env(&config.target).unwrap_or("")) - } fn ignore_gdb(config: &Config, line: &str) -> bool { if config.mode != common::DebugInfoGdb { return false; } - if config.parse_name_directive(line, "ignore-gdb") { - return true; - } - if let Some(actual_version) = config.gdb_version { if line.starts_with("min-gdb-version") { let (start_ver, end_ver) = extract_gdb_version_range(line); @@ -144,10 +120,6 @@ impl EarlyProps { return false; } - if config.parse_name_directive(line, "ignore-lldb") { - return true; - } - if let Some(ref actual_version) = config.lldb_version { if line.starts_with("min-lldb-version") { let min_version = line.trim_right() @@ -525,6 +497,30 @@ impl Config { } } + /// Parses a name-value directive which contains config-specific information, e.g. `ignore-x86` + /// or `normalize-stderr-32bit`. Returns `true` if the line matches it. + fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> bool { + if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') { + let name = line[prefix.len()+1 ..].split(&[':', ' '][..]).next().unwrap(); + + name == "test" || + name == util::get_os(&self.target) || // target + name == util::get_arch(&self.target) || // architecture + name == util::get_pointer_width(&self.target) || // pointer width + name == self.stage_id.split('-').next().unwrap() || // stage + Some(name) == util::get_env(&self.target) || // env + match self.mode { + common::DebugInfoGdb => name == "gdb", + common::DebugInfoLldb => name == "lldb", + common::Pretty => name == "pretty", + _ => false, + } || + (self.target != self.host && name == "cross-compile") + } else { + false + } + } + fn parse_name_directive(&self, line: &str, directive: &str) -> bool { // Ensure the directive is a whole word. Do not match "ignore-x86" when // the line says "ignore-x86_64". diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 4202356bd97..85fa38bbd3b 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -72,6 +72,14 @@ pub fn get_env(triple: &str) -> Option<&str> { triple.split('-').nth(3) } +pub fn get_pointer_width(triple: &str) -> &'static str { + if triple.contains("64") || triple.starts_with("s390x") { + "64bit" + } else { + "32bit" + } +} + pub fn make_new_path(path: &str) -> String { assert!(cfg!(windows)); // Windows just uses PATH as the library search path, so we have to