diff --git a/src/test/ui/command/command-current-dir.rs b/src/test/ui/command/command-current-dir.rs index a1a72a14958d..91d8e4f381a3 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();