rust/0002-Use-env-split_paths-jo...

64 lines
3.0 KiB
Diff

From 642e12326055268c7605b31e7f91edf8f58e54d4 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Thu, 11 Apr 2024 15:33:44 -0700
Subject: [PATCH 2/2] Use `env::split_paths`/`join_paths` in runtest
(cherry picked from commit 7e171c72cbddb0636fa8ce71a0e862486ae72625)
---
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 3c775ea0651c..852ffa0a62a8 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -3767,10 +3767,13 @@ fn run_rmake_v2_test(&self) {
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 res = self.cmd2procres(
Command::new(&self.config.rustc_path)
@@ -3810,19 +3813,15 @@ fn run_rmake_v2_test(&self) {
// 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)
--
2.44.0