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.
This commit is contained in:
Tom Eccles 2020-05-28 16:27:56 +01:00
parent eeaf497b2a
commit 1b7ec76c16
2 changed files with 15 additions and 8 deletions

View file

@ -224,7 +224,7 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
// by the client.
for (k, v) in env::vars() {
match &k[..] {
"PATH" | "LD_LIBRARY_PATH" | "PWD" => continue,
"PATH" | "LD_LIBRARY_PATH" | "PWD" | "RUST_TEST_TMPDIR" => continue,
_ => {}
}
t!(client.write_all(k.as_bytes()));

View file

@ -83,16 +83,19 @@ fn main() {
};
let listener = t!(TcpListener::bind(bind_addr));
let work: PathBuf = if cfg!(target_os = "android") {
"/data/tmp/work".into()
let (work, tmp): (PathBuf, PathBuf) = if cfg!(target_os = "android") {
("/data/tmp/work".into(), "/data/tmp/work/tmp".into())
} else {
let mut temp_dir = env::temp_dir();
temp_dir.push("work");
temp_dir
let mut work_dir = env::temp_dir();
work_dir.push("work");
let mut tmp_dir = work_dir.clone();
tmp_dir.push("tmp");
(work_dir, tmp_dir)
};
println!("listening!");
t!(fs::create_dir_all(&work));
t!(fs::create_dir_all(&tmp));
let lock = Arc::new(Mutex::new(()));
@ -109,7 +112,8 @@ fn main() {
} else if &buf[..] == b"run " {
let lock = lock.clone();
let work = work.clone();
thread::spawn(move || handle_run(socket, &work, &lock));
let tmp = tmp.clone();
thread::spawn(move || handle_run(socket, &work, &tmp, &lock));
} else {
panic!("unknown command {:?}", buf);
}
@ -134,7 +138,7 @@ impl Drop for RemoveOnDrop<'_> {
}
}
fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>) {
let mut arg = Vec::new();
let mut reader = BufReader::new(socket);
@ -226,6 +230,9 @@ fn handle_run(socket: TcpStream, work: &Path, lock: &Mutex<()>) {
cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display()));
}
// Some tests assume RUST_TEST_TMPDIR exists
cmd.env("RUST_TEST_TMPDIR", tmp.to_owned());
// Spawn the child and ferry over stdout/stderr to the socket in a framed
// fashion (poor man's style)
let mut child =