Skip to content

Commit c7e54d7

Browse files
michaelwoeristernikomatsakis
authored andcommitted
Make library paths passed by compiletest tool absolute.
Otherwise, changing the current working directory can mess up runtime linking.
1 parent 606c985 commit c7e54d7

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/compiletest/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ impl fmt::Display for Mode {
6969
#[derive(Clone)]
7070
pub struct Config {
7171
// The library paths required for running the compiler
72-
pub compile_lib_path: String,
72+
pub compile_lib_path: PathBuf,
7373

7474
// The library paths required for running compiled programs
75-
pub run_lib_path: String,
75+
pub run_lib_path: PathBuf,
7676

7777
// The rustc executable
7878
pub rustc_path: PathBuf,

src/compiletest/compiletest.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,23 @@ pub fn parse_config(args: Vec<String> ) -> Config {
118118
}
119119
}
120120

121+
fn make_absolute(path: PathBuf) -> PathBuf {
122+
if path.is_relative() {
123+
env::current_dir().unwrap().join(path)
124+
} else {
125+
path
126+
}
127+
}
128+
129+
let filter = if !matches.free.is_empty() {
130+
Some(matches.free[0].clone())
131+
} else {
132+
None
133+
};
134+
121135
Config {
122-
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
123-
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
136+
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
137+
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
124138
rustc_path: opt_path(matches, "rustc-path"),
125139
rustdoc_path: opt_path(matches, "rustdoc-path"),
126140
python: matches.opt_str("python").unwrap(),

src/compiletest/runtest.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn run_pretty_test_revision(config: &Config,
316316
testpaths,
317317
pretty_type.to_owned()),
318318
props.exec_env.clone(),
319-
&config.compile_lib_path,
319+
config.compile_lib_path.to_str().unwrap(),
320320
Some(aux_dir.to_str().unwrap()),
321321
Some(src))
322322
}
@@ -635,7 +635,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testpaths: &TestPa
635635
testpaths,
636636
proc_args,
637637
environment,
638-
&config.run_lib_path,
638+
config.run_lib_path.to_str().unwrap(),
639639
None,
640640
None);
641641
}
@@ -1315,7 +1315,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
13151315
testpaths,
13161316
make_run_args(config, props, testpaths),
13171317
env,
1318-
&config.run_lib_path,
1318+
config.run_lib_path.to_str().unwrap(),
13191319
Some(aux_dir.to_str().unwrap()),
13201320
None)
13211321
}
@@ -1387,7 +1387,7 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
13871387
&aux_testpaths,
13881388
aux_args,
13891389
Vec::new(),
1390-
&config.compile_lib_path,
1390+
config.compile_lib_path.to_str().unwrap(),
13911391
Some(aux_dir.to_str().unwrap()),
13921392
None);
13931393
if !auxres.status.success() {
@@ -1410,7 +1410,7 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
14101410
testpaths,
14111411
args,
14121412
props.rustc_env.clone(),
1413-
&config.compile_lib_path,
1413+
config.compile_lib_path.to_str().unwrap(),
14141414
Some(aux_dir.to_str().unwrap()),
14151415
input)
14161416
}

0 commit comments

Comments
 (0)