From 877e7f346396c8893ff9173e5b485a0205ef11ce Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Tue, 3 Sep 2013 19:34:23 +0900 Subject: [PATCH] Correctly determine OS to xfail in cross build --- src/compiletest/header.rs | 8 ++++---- src/compiletest/util.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 5e3687d7057..38cb7c7bfe0 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -10,9 +10,9 @@ use common::config; use common; +use util; use std::io; -use std::os; pub struct TestProps { // Lines that should be expected, in order, on standard out @@ -89,13 +89,13 @@ pub fn load_props(testfile: &Path) -> TestProps { } pub fn is_test_ignored(config: &config, testfile: &Path) -> bool { - fn xfail_target() -> ~str { - ~"xfail-" + os::SYSNAME + fn xfail_target(config: &config) -> ~str { + ~"xfail-" + util::get_os(config.target) } let val = do iter_header(testfile) |ln| { if parse_name_directive(ln, "xfail-test") { false } - else if parse_name_directive(ln, xfail_target()) { false } + else if parse_name_directive(ln, xfail_target(config)) { false } else if config.mode == common::mode_pretty && parse_name_directive(ln, "xfail-pretty") { false } else { true } diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 5af469ff841..b62d26a5029 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -13,6 +13,25 @@ use std::io; use std::os::getenv; +/// Conversion table from triple OS name to Rust SYSNAME +static OS_TABLE: &'static [(&'static str, &'static str)] = &[ + ("mingw32", "win32"), + ("win32", "win32"), + ("darwin", "macos"), + ("android", "android"), + ("linux", "linux"), + ("freebsd", "freebsd"), +]; + +pub fn get_os(triple: &str) -> &'static str { + for &(triple_os, os) in OS_TABLE.iter() { + if triple.contains(triple_os) { + return os + } + } + fail!("Cannot determine OS from triple"); +} + pub fn make_new_path(path: &str) -> ~str { // Windows just uses PATH as the library search path, so we have to