Skip to content

Commit 850ddbf

Browse files
committed
Test Command::current_dir with verbatim path
1 parent aa8f0fd commit 850ddbf

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Test that windows `creation_flags` extension to `Command` works.
2+
3+
//@ run-pass
4+
//@ only-windows
5+
//@ needs-subprocess
6+
7+
use std::process::Command;
8+
use std::{env, fs};
9+
10+
fn main() {
11+
if env::args().skip(1).any(|s| s == "--child") {
12+
child();
13+
} else {
14+
parent();
15+
}
16+
}
17+
18+
fn parent() {
19+
let exe = env::current_exe().unwrap();
20+
let dir = env::current_dir().unwrap();
21+
let status = Command::new(&exe)
22+
.arg("--child")
23+
.current_dir(fs::canonicalize(dir).unwrap())
24+
.spawn()
25+
.unwrap()
26+
.wait()
27+
.unwrap();
28+
assert_eq!(status.code(), Some(0));
29+
}
30+
31+
fn child() {
32+
let current_dir = env::current_dir().unwrap();
33+
let current_dir = current_dir.as_os_str().as_encoded_bytes();
34+
assert!(!current_dir.starts_with(br"\\?\"));
35+
}

0 commit comments

Comments
 (0)