Skip to content

Commit 4b0842f

Browse files
committed
Small refactoring
1 parent d86c981 commit 4b0842f

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/tools/run-make-support/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub fn set_host_rpath(cmd: &mut Command) {
227227
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
228228
cmd.env(&ld_lib_path_envvar, {
229229
let mut paths = vec![];
230-
paths.push(env::current_dir().unwrap());
230+
paths.push(cwd());
231231
paths.push(PathBuf::from(env_var("HOST_RPATH_DIR")));
232232
for p in env::split_paths(&env_var(&ld_lib_path_envvar)) {
233233
paths.push(p.to_path_buf());
@@ -325,9 +325,8 @@ pub fn assert_not_contains(haystack: &str, needle: &str) {
325325
/// 4) Calls `callback`
326326
/// 5) Switches working directory back to the original one
327327
/// 6) Removes `tmpdir`
328-
/// Switch current working directory to a temporary directory
329328
pub fn run_in_tmpdir<F: FnOnce()>(callback: F) {
330-
let original_dir = env::current_dir().unwrap();
329+
let original_dir = cwd();
331330
let tmpdir = original_dir.join("../temporary-directory");
332331
copy_dir_all(".", &tmpdir);
333332

src/tools/run-make-support/src/run.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ use std::env;
22
use std::path::{Path, PathBuf};
33
use std::process::{Command, Output};
44

5-
use crate::{env_var, is_windows};
5+
use crate::{cwd, env_var, is_windows};
66

77
use super::handle_failed_output;
88

99
fn run_common(name: &str) -> (Command, Output) {
1010
let mut bin_path = PathBuf::new();
11-
bin_path.push(env::current_dir().unwrap());
11+
bin_path.push(cwd());
1212
bin_path.push(name);
1313
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
1414
let mut cmd = Command::new(bin_path);
1515
cmd.env(&ld_lib_path_envvar, {
1616
let mut paths = vec![];
17-
paths.push(env::current_dir().unwrap());
17+
paths.push(cwd());
1818
for p in env::split_paths(&env_var("TARGET_RPATH_ENV")) {
1919
paths.push(p.to_path_buf());
2020
}

src/tools/run-make-support/src/rustc.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use std::env;
21
use std::ffi::{OsStr, OsString};
32
use std::io::Write;
43
use std::path::Path;
54
use std::process::{Command, Output, Stdio};
65

7-
use crate::{env_var, handle_failed_output, set_host_rpath};
6+
use crate::{cwd, env_var, handle_failed_output, set_host_rpath};
87

98
/// Construct a new `rustc` invocation.
109
pub fn rustc() -> Rustc {
@@ -29,7 +28,7 @@ fn setup_common() -> Command {
2928
let rustc = env_var("RUSTC");
3029
let mut cmd = Command::new(rustc);
3130
set_host_rpath(&mut cmd);
32-
cmd.arg("-L").arg(env::current_dir().unwrap());
31+
cmd.arg("-L").arg(cwd());
3332
cmd
3433
}
3534

0 commit comments

Comments
 (0)