about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-08-08 10:28:05 +0200
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-08-10 18:32:06 +0200
commit33ff32cac8324ee3fcae09baa1c571c701f1157e (patch)
treec9993c5033134475e840e287bdff6542b0af577a
parent63c48435030c3f3057aa9da8ffb4be8389896050 (diff)
downloadrust-33ff32cac8324ee3fcae09baa1c571c701f1157e.tar.gz
rust-33ff32cac8324ee3fcae09baa1c571c701f1157e.zip
Get the test suite working inside the rustc test suite
-rw-r--r--tests/compiletest.rs41
1 files changed, 35 insertions, 6 deletions
diff --git a/tests/compiletest.rs b/tests/compiletest.rs
index 7493551ecf7..78886d96413 100644
--- a/tests/compiletest.rs
+++ b/tests/compiletest.rs
@@ -13,7 +13,21 @@ macro_rules! eprintln {
     }
 }
 
-const MIRI_PATH: &'static str = concat!("target/", env!("PROFILE"), "/miri");
+fn miri_path() -> PathBuf {
+    if rustc_test_suite().is_some() {
+        PathBuf::from(option_env!("MIRI_PATH").unwrap())
+    } else {
+        PathBuf::from(concat!("target/", env!("PROFILE"), "/miri"))
+    }
+}
+
+fn rustc_test_suite() -> Option<PathBuf> {
+    option_env!("RUSTC_TEST_SUITE").map(PathBuf::from)
+}
+
+fn rustc_lib_path() -> PathBuf {
+    option_env!("RUSTC_LIB_PATH").unwrap().into()
+}
 
 fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: bool) {
     eprintln!(
@@ -23,9 +37,14 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
     );
     let mut config = compiletest::default_config();
     config.mode = "compile-fail".parse().expect("Invalid mode");
-    config.rustc_path = MIRI_PATH.into();
+    config.rustc_path = miri_path();
     let mut flags = Vec::new();
-    if fullmir {
+    if rustc_test_suite().is_some() {
+        config.run_lib_path = rustc_lib_path();
+        config.compile_lib_path = rustc_lib_path();
+    }
+    // if we are building as part of the rustc test suite, we already have fullmir for everything
+    if fullmir && rustc_test_suite().is_none() {
         if host != target {
             // skip fullmir on nonhost
             return;
@@ -50,7 +69,12 @@ fn run_pass(path: &str) {
     let mut config = compiletest::default_config();
     config.mode = "run-pass".parse().expect("Invalid mode");
     config.src_base = PathBuf::from(path);
-    config.target_rustcflags = Some("-Dwarnings".to_string());
+    if let Some(rustc_path) = rustc_test_suite() {
+        config.rustc_path = rustc_path;
+        config.run_lib_path = rustc_lib_path();
+        config.compile_lib_path = rustc_lib_path();
+    }
+    config.target_rustcflags = Some(format!("-Dwarnings --sysroot {}", get_sysroot().display()));
     config.host_rustcflags = Some("-Dwarnings".to_string());
     compiletest::run_tests(&config);
 }
@@ -68,9 +92,14 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
     config.src_base = PathBuf::from(path);
     config.target = target.to_owned();
     config.host = host.to_owned();
-    config.rustc_path = MIRI_PATH.into();
+    config.rustc_path = miri_path();
+    if rustc_test_suite().is_some() {
+        config.run_lib_path = rustc_lib_path();
+        config.compile_lib_path = rustc_lib_path();
+    }
     let mut flags = Vec::new();
-    if fullmir {
+    // if we are building as part of the rustc test suite, we already have fullmir for everything
+    if fullmir && rustc_test_suite().is_none() {
         if host != target {
             // skip fullmir on nonhost
             return;