]> git.lizzy.rs Git - rust.git/commitdiff
Make library paths passed by compiletest tool absolute.
authorMichael Woerister <michaelwoerister@posteo.net>
Mon, 29 Feb 2016 13:44:06 +0000 (08:44 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 25 Mar 2016 18:07:17 +0000 (14:07 -0400)
Otherwise, changing the current working directory can mess up runtime linking.

src/compiletest/common.rs
src/compiletest/compiletest.rs
src/compiletest/runtest.rs

index 33ec974c52739358b33a2e462969a6f5c0f735b0..bfcc1759b955d4aa6256ea5706bb3a17b4988537 100644 (file)
@@ -69,10 +69,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 #[derive(Clone)]
 pub struct Config {
     // The library paths required for running the compiler
-    pub compile_lib_path: String,
+    pub compile_lib_path: PathBuf,
 
     // The library paths required for running compiled programs
-    pub run_lib_path: String,
+    pub run_lib_path: PathBuf,
 
     // The rustc executable
     pub rustc_path: PathBuf,
index 96b52eaa0ad0fb67bf95d7506c09c49fc026c877..51bc9d71f883c19ce9b1f4f67d685fb611db6b5b 100644 (file)
@@ -118,9 +118,23 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> PathBuf {
         }
     }
 
+    fn make_absolute(path: PathBuf) -> PathBuf {
+        if path.is_relative() {
+            env::current_dir().unwrap().join(path)
+        } else {
+            path
+        }
+    }
+
+    let filter = if !matches.free.is_empty() {
+        Some(matches.free[0].clone())
+    } else {
+        None
+    };
+
     Config {
-        compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
-        run_lib_path: matches.opt_str("run-lib-path").unwrap(),
+        compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
+        run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
         rustc_path: opt_path(matches, "rustc-path"),
         rustdoc_path: opt_path(matches, "rustdoc-path"),
         python: matches.opt_str("python").unwrap(),
index 5293eee9459cf1728f4964084ce15b0bc6dba80c..efad2038f82f793a3861220c1f98e58115dfdede 100644 (file)
@@ -316,7 +316,7 @@ fn print_source(config: &Config,
                                      testpaths,
                                      pretty_type.to_owned()),
                         props.exec_env.clone(),
-                        &config.compile_lib_path,
+                        config.compile_lib_path.to_str().unwrap(),
                         Some(aux_dir.to_str().unwrap()),
                         Some(src))
     }
@@ -635,7 +635,7 @@ fn debugger() -> &'static str {
                                                   testpaths,
                                                   proc_args,
                                                   environment,
-                                                  &config.run_lib_path,
+                                                  config.run_lib_path.to_str().unwrap(),
                                                   None,
                                                   None);
         }
@@ -1315,7 +1315,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
                             testpaths,
                             make_run_args(config, props, testpaths),
                             env,
-                            &config.run_lib_path,
+                            config.run_lib_path.to_str().unwrap(),
                             Some(aux_dir.to_str().unwrap()),
                             None)
         }
@@ -1387,7 +1387,7 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
                                      &aux_testpaths,
                                      aux_args,
                                      Vec::new(),
-                                     &config.compile_lib_path,
+                                     config.compile_lib_path.to_str().unwrap(),
                                      Some(aux_dir.to_str().unwrap()),
                                      None);
         if !auxres.status.success() {
@@ -1410,7 +1410,7 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
                     testpaths,
                     args,
                     props.rustc_env.clone(),
-                    &config.compile_lib_path,
+                    config.compile_lib_path.to_str().unwrap(),
                     Some(aux_dir.to_str().unwrap()),
                     input)
 }