Skip to content

Commit 1b7ec76

Browse files
committed
tools/remote-test-{server,client}: support RUST_TEST_TMPDIR
Some tests (e.g. ui-fulldeps/create-dir-all-bare.rs) assume that RUST_TEST_TMPDIR exists on the system running the test. Expand remote-test-{server,client} such that a tmp directory is created on the remote runner and this environment variable will point at it.
1 parent eeaf497 commit 1b7ec76

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/tools/remote-test-client/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
224224
// by the client.
225225
for (k, v) in env::vars() {
226226
match &k[..] {
227-
"PATH" | "LD_LIBRARY_PATH" | "PWD" => continue,
227+
"PATH" | "LD_LIBRARY_PATH" | "PWD" | "RUST_TEST_TMPDIR" => continue,
228228
_ => {}
229229
}
230230
t!(client.write_all(k.as_bytes()));

src/tools/remote-test-server/src/main.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,19 @@ fn main() {
8383
};
8484

8585
let listener = t!(TcpListener::bind(bind_addr));
86-
let work: PathBuf = if cfg!(target_os = "android") {
87-
"/data/tmp/work".into()
86+
let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
87+
("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
8888
} else {
89-
let mut temp_dir = env::temp_dir();
90-
temp_dir.push("work");
91-
temp_dir
89+
let mut work_dir = env::temp_dir();
90+
work_dir.push("work");
91+
let mut tmp_dir = work_dir.clone();
92+
tmp_dir.push("tmp");
93+
(work_dir, tmp_dir)
9294
};
9395
println!("listening!");
9496

9597
t!(fs::create_dir_all(&work));
98+
t!(fs::create_dir_all(&tmp));
9699

97100
let lock = Arc::new(Mutex::new(()));
98101

@@ -109,7 +112,8 @@ fn main() {
109112
} else if &buf[..] == b"run " {
110113
let lock = lock.clone();
111114
let work = work.clone();
112-
thread::spawn(move || handle_run(socket, &work, &lock));
115+
let tmp = tmp.clone();
116+
thread::spawn(move || handle_run(socket, &work, &tmp, &lock));
113117
} else {
114118
panic!("unknown command {:?}", buf);
115119
}
@@ -134,7 +138,7 @@ impl Drop for RemoveOnDrop<'_> {
134138
}
135139
}
136140

137-
fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
141+
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) {
138142
let mut arg = Vec::new();
139143
let mut reader = BufReader::new(socket);
140144

@@ -226,6 +230,9 @@ fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
226230
cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display()));
227231
}
228232

233+
// Some tests assume RUST_TEST_TMPDIR exists
234+
cmd.env("RUST_TEST_TMPDIR", tmp.to_owned());
235+
229236
// Spawn the child and ferry over stdout/stderr to the socket in a framed
230237
// fashion (poor man's style)
231238
let mut child =

0 commit comments

Comments
 (0)