about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2021-01-17 14:03:23 -0800
committerEric Huss <eric@huss.org>2021-01-17 14:03:23 -0800
commit6e467b74cda020f89f1663deda5169f85d859c6d (patch)
tree9915bdced5f51c4866c771adfd1cacc5e29b4e72
parentfcbcc975767b0621a43fb9c1c872e1754e30a377 (diff)
downloadrust-6e467b74cda020f89f1663deda5169f85d859c6d.tar.gz
rust-6e467b74cda020f89f1663deda5169f85d859c6d.zip
Fix test to work with remote-test-server.
remote-test-server does not set the current_dir, and leaves it
as `/`.
-rw-r--r--src/test/ui/command/command-current-dir.rs8
1 files changed, 7 insertions, 1 deletions
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();