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`.
This commit is contained in:
kennytm 2017-07-06 11:25:29 +08:00
parent 1999bfaa9f
commit 18712e6edf
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
3 changed files with 35 additions and 36 deletions

View file

@ -13,12 +13,7 @@
// should look like.
// ignore-windows
// Ignore 32 bit targets:
// ignore-x86
// ignore-arm
// ignore-emscripten
// ignore-32bit
#![feature(i128_type)]

View file

@ -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("<unknown>"))
}
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".

View file

@ -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