From 6e467b74cda020f89f1663deda5169f85d859c6d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 17 Jan 2021 14:03:23 -0800 Subject: [PATCH] Fix test to work with remote-test-server. remote-test-server does not set the current_dir, and leaves it as `/`. --- src/test/ui/command/command-current-dir.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/ui/command/command-current-dir.rs b/src/test/ui/command/command-current-dir.rs index a1a72a14958..91d8e4f381a 100644 --- a/src/test/ui/command/command-current-dir.rs +++ b/src/test/ui/command/command-current-dir.rs @@ -16,8 +16,14 @@ fn main() { std::process::exit(0); } let exe = me.file_name().unwrap(); - let cwd = std::env::current_dir().unwrap(); + let cwd = me.parent().unwrap(); eprintln!("cwd={:?}", cwd); + // Change directory to where the exectuable is located, since this test + // fundamentally needs to use relative paths. In some cases (like + // remote-test-server), the current_dir can be somewhere else, so make + // sure it is something we can use. We assume we can write to this + // directory. + env::set_current_dir(&cwd).unwrap(); let foo = cwd.join("foo"); let bar = cwd.join("bar"); fs::create_dir_all(&foo).unwrap();