about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/process/win-command-curdir-no-verbatim.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/ui/process/win-command-curdir-no-verbatim.rs b/tests/ui/process/win-command-curdir-no-verbatim.rs
new file mode 100644
index 00000000000..99943e1c8ab
--- /dev/null
+++ b/tests/ui/process/win-command-curdir-no-verbatim.rs
@@ -0,0 +1,36 @@
+// Test that windows verbatim paths in `Command::current_dir` are converted to
+// non-verbatim paths before passing to the subprocess.
+
+//@ run-pass
+//@ only-windows
+//@ needs-subprocess
+
+use std::env;
+use std::process::Command;
+
+fn main() {
+    if env::args().skip(1).any(|s| s == "--child") {
+        child();
+    } else {
+        parent();
+    }
+}
+
+fn parent() {
+    let exe = env::current_exe().unwrap();
+    let dir = env::current_dir().unwrap();
+    let status = Command::new(&exe)
+        .arg("--child")
+        .current_dir(dir.canonicalize().unwrap())
+        .spawn()
+        .unwrap()
+        .wait()
+        .unwrap();
+    assert_eq!(status.code(), Some(0));
+}
+
+fn child() {
+    let current_dir = env::current_dir().unwrap();
+    let current_dir = current_dir.as_os_str().as_encoded_bytes();
+    assert!(!current_dir.starts_with(br"\\?\"));
+}