Skip to content

Commit

Permalink
Use env::split_paths/join_paths in runtest
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Apr 11, 2024
1 parent 8a5409b commit 7e171c7
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3785,10 +3785,13 @@ impl<'test> TestCx<'test> {
debug!(?support_lib_deps);
debug!(?support_lib_deps_deps);

let mut host_dylib_env_paths = String::new();
host_dylib_env_paths.push_str(&cwd.join(&self.config.compile_lib_path).to_string_lossy());
host_dylib_env_paths.push(':');
host_dylib_env_paths.push_str(&env::var(dylib_env_var()).unwrap());
let orig_dylib_env_paths =
Vec::from_iter(env::split_paths(&env::var(dylib_env_var()).unwrap()));

let mut host_dylib_env_paths = Vec::new();
host_dylib_env_paths.push(cwd.join(&self.config.compile_lib_path));
host_dylib_env_paths.extend(orig_dylib_env_paths.iter().cloned());
let host_dylib_env_paths = env::join_paths(host_dylib_env_paths).unwrap();

let mut cmd = Command::new(&self.config.rustc_path);
cmd.arg("-o")
Expand Down Expand Up @@ -3834,19 +3837,15 @@ impl<'test> TestCx<'test> {
// Finally, we need to run the recipe binary to build and run the actual tests.
debug!(?recipe_bin);

let mut dylib_env_paths = String::new();
dylib_env_paths.push_str(&env::var(dylib_env_var()).unwrap());
dylib_env_paths.push(':');
dylib_env_paths.push_str(&support_lib_path.parent().unwrap().to_string_lossy());
dylib_env_paths.push(':');
dylib_env_paths.push_str(
&stage_std_path.join("rustlib").join(&self.config.host).join("lib").to_string_lossy(),
);
let mut dylib_env_paths = orig_dylib_env_paths.clone();
dylib_env_paths.push(support_lib_path.parent().unwrap().to_path_buf());
dylib_env_paths.push(stage_std_path.join("rustlib").join(&self.config.host).join("lib"));
let dylib_env_paths = env::join_paths(dylib_env_paths).unwrap();

let mut target_rpath_env_path = String::new();
target_rpath_env_path.push_str(&tmpdir.to_string_lossy());
target_rpath_env_path.push(':');
target_rpath_env_path.push_str(&dylib_env_paths);
let mut target_rpath_env_path = Vec::new();
target_rpath_env_path.push(&tmpdir);
target_rpath_env_path.extend(&orig_dylib_env_paths);
let target_rpath_env_path = env::join_paths(target_rpath_env_path).unwrap();

let mut cmd = Command::new(&recipe_bin);
cmd.current_dir(&self.testpaths.file)
Expand Down

0 comments on commit 7e171c7

Please sign in to comment.