File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Test that windows verbatim paths in `Command::current_dir` are converted to
2
+ // non-verbatim paths before passing to the subprocess.
3
+
4
+ //@ run-pass
5
+ //@ only-windows
6
+ //@ needs-subprocess
7
+
8
+ use std:: env;
9
+ use std:: process:: Command ;
10
+
11
+ fn main ( ) {
12
+ if env:: args ( ) . skip ( 1 ) . any ( |s| s == "--child" ) {
13
+ child ( ) ;
14
+ } else {
15
+ parent ( ) ;
16
+ }
17
+ }
18
+
19
+ fn parent ( ) {
20
+ let exe = env:: current_exe ( ) . unwrap ( ) ;
21
+ let dir = env:: current_dir ( ) . unwrap ( ) ;
22
+ let status = Command :: new ( & exe)
23
+ . arg ( "--child" )
24
+ . current_dir ( dir. canonicalize ( ) . unwrap ( ) )
25
+ . spawn ( )
26
+ . unwrap ( )
27
+ . wait ( )
28
+ . unwrap ( ) ;
29
+ assert_eq ! ( status. code( ) , Some ( 0 ) ) ;
30
+ }
31
+
32
+ fn child ( ) {
33
+ let current_dir = env:: current_dir ( ) . unwrap ( ) ;
34
+ let current_dir = current_dir. as_os_str ( ) . as_encoded_bytes ( ) ;
35
+ assert ! ( !current_dir. starts_with( br"\\?\" ) ) ;
36
+ }
You can’t perform that action at this time.
0 commit comments