From 7e171c72cbddb0636fa8ce71a0e862486ae72625 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 11 Apr 2024 15:33:44 -0700 Subject: [PATCH] Use `env::split_paths`/`join_paths` in runtest --- src/tools/compiletest/src/runtest.rs | 31 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a0ef798201e79..5212f1430d831 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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") @@ -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)