Skip to content

Commit

Permalink
Make library paths passed by compiletest tool absolute.
Browse files Browse the repository at this point in the history
Otherwise, changing the current working directory can mess up runtime linking.
  • Loading branch information
michaelwoerister authored and nikomatsakis committed Mar 25, 2016
1 parent 606c985 commit c7e54d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/compiletest/common.rs
Expand Up @@ -69,10 +69,10 @@ impl fmt::Display for Mode {
#[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,
Expand Down
18 changes: 16 additions & 2 deletions src/compiletest/compiletest.rs
Expand Up @@ -118,9 +118,23 @@ pub fn parse_config(args: Vec<String> ) -> Config {
}
}

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(),
Expand Down
10 changes: 5 additions & 5 deletions src/compiletest/runtest.rs
Expand Up @@ -316,7 +316,7 @@ fn run_pretty_test_revision(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))
}
Expand Down Expand Up @@ -635,7 +635,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testpaths: &TestPa
testpaths,
proc_args,
environment,
&config.run_lib_path,
config.run_lib_path.to_str().unwrap(),
None,
None);
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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() {
Expand All @@ -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)
}
Expand Down

0 comments on commit c7e54d7

Please sign in to comment.