From 4497ee3f0eb29d0ae84f2b64866c9862bdbfaf77 Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Sat, 13 Dec 2014 09:38:55 +0000 Subject: [PATCH 1/3] Enable ignoring tests based on architecture. --- src/compiletest/header.rs | 8 ++++++-- src/compiletest/util.rs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 60ef76528e849..06aa4849057fa 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -144,9 +144,12 @@ pub fn load_props(testfile: &Path) -> TestProps { } pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool { - fn ignore_target(config: &Config) -> String { + fn ignore_os(config: &Config) -> String { format!("ignore-{}", util::get_os(config.target.as_slice())) } + fn ignore_arch(config: &Config) -> String { + format!("ignore-{}", util::get_arch(config.target.as_slice())) + } fn ignore_stage(config: &Config) -> String { format!("ignore-{}", config.stage_id.as_slice().split('-').next().unwrap()) @@ -209,7 +212,8 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool { let val = iter_header(testfile, |ln| { !parse_name_directive(ln, "ignore-test") && - !parse_name_directive(ln, ignore_target(config).as_slice()) && + !parse_name_directive(ln, ignore_os(config).as_slice()) && + !parse_name_directive(ln, ignore_arch(config).as_slice()) && !parse_name_directive(ln, ignore_stage(config).as_slice()) && !(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) && !(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) && diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index a116cc33690db..0713494b1d8e7 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -25,6 +25,15 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[ ("dragonfly", "dragonfly"), ]; +/// Table to help extracting architecture from triple +static ARCH_TABLE: &'static [&'static str] = &[ + "arm", + "mips", + "mipsel", + "x86", + "x86_64", +]; + pub fn get_os(triple: &str) -> &'static str { for &(triple_os, os) in OS_TABLE.iter() { if triple.contains(triple_os) { @@ -34,6 +43,15 @@ pub fn get_os(triple: &str) -> &'static str { panic!("Cannot determine OS from triple"); } +pub fn get_arch(triple: &str) -> &'static str { + for &triple_arch in ARCH_TABLE.iter() { + if triple.contains(triple_arch) { + return triple_arch + } + } + panic!("Cannot determine architecture from triple"); +} + #[cfg(target_os = "windows")] pub fn make_new_path(path: &str) -> String { From 3a7ec877ad06bf0bebae0bb6fadf704aff7e1b9a Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Mon, 15 Dec 2014 09:58:16 +0000 Subject: [PATCH 2/3] Reordering ARCH_TABLE so that substrings come later and util::get_arch can correctly determine the architecture. (So, x86_64 will not be identified as x86, and mipsel will not be identified as mips.) --- src/compiletest/header.rs | 2 +- src/compiletest/util.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 06aa4849057fa..3dd3f8b1254df 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 0713494b1d8e7..008d95330b462 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -28,10 +28,10 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[ /// Table to help extracting architecture from triple static ARCH_TABLE: &'static [&'static str] = &[ "arm", - "mips", "mipsel", - "x86", + "mips", "x86_64", + "x86", ]; pub fn get_os(triple: &str) -> &'static str { From e92f4320e7e6f8d62898adc9857b7b0e3f463a8b Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Mon, 15 Dec 2014 23:28:30 +0000 Subject: [PATCH 3/3] Rewriting fn ignore_arch() to determine architecture from target triple by splitting at '-' (instead of relying on tables and .contains). This makes previous changes to util.rs unnecessary. --- src/compiletest/header.rs | 3 ++- src/compiletest/util.rs | 20 +------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 3dd3f8b1254df..50fe42b8fee9c 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -148,7 +148,8 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool { format!("ignore-{}", util::get_os(config.target.as_slice())) } fn ignore_arch(config: &Config) -> String { - format!("ignore-{}", util::get_arch(config.target.as_slice())) + format!("ignore-{}", + config.target.as_slice().split('-').next().unwrap()) } fn ignore_stage(config: &Config) -> String { format!("ignore-{}", diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 008d95330b462..a116cc33690db 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -1,4 +1,4 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -25,15 +25,6 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[ ("dragonfly", "dragonfly"), ]; -/// Table to help extracting architecture from triple -static ARCH_TABLE: &'static [&'static str] = &[ - "arm", - "mipsel", - "mips", - "x86_64", - "x86", -]; - pub fn get_os(triple: &str) -> &'static str { for &(triple_os, os) in OS_TABLE.iter() { if triple.contains(triple_os) { @@ -43,15 +34,6 @@ pub fn get_os(triple: &str) -> &'static str { panic!("Cannot determine OS from triple"); } -pub fn get_arch(triple: &str) -> &'static str { - for &triple_arch in ARCH_TABLE.iter() { - if triple.contains(triple_arch) { - return triple_arch - } - } - panic!("Cannot determine architecture from triple"); -} - #[cfg(target_os = "windows")] pub fn make_new_path(path: &str) -> String {