File tree 1 file changed +12
-6
lines changed
tests/run-make/windows-binary-no-external-deps
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change
1
+ //! Ensure that we aren't relying on any non-system DLLs when running
2
+ //! a "hello world" application by setting `PATH` to `C:\Windows\System32`.
1
3
//@ only-windows
2
4
3
- // Ensure that we aren't relying on any non-system DLLs when compiling and running
4
- // a "hello world" application by setting `PATH` to `C:\Windows\System32`.
5
-
6
- use run_make_support:: { run, rustc} ;
5
+ use run_make_support:: { rustc, tmp_dir} ;
7
6
use std:: env;
8
7
use std:: path:: PathBuf ;
8
+ use std:: process:: Command ;
9
9
10
10
fn main ( ) {
11
+ rustc ( ) . input ( "hello.rs" ) . run ( ) ;
12
+
11
13
let windows_dir = env:: var ( "SystemRoot" ) . unwrap ( ) ;
12
14
let system32: PathBuf = [ & windows_dir, "System32" ] . iter ( ) . collect ( ) ;
13
- rustc ( ) . input ( "hello.rs" ) . env ( "PATH" , system32) . run ( ) ;
14
- run ( "hello" ) ;
15
+ // Note: This does not use the support wrappers so that we can precisely control the PATH
16
+ let exe = tmp_dir ( ) . join ( "hello.exe" ) ;
17
+ let status = Command :: new ( exe) . env ( "PATH" , & system32) . spawn ( ) . unwrap ( ) . wait ( ) . unwrap ( ) ;
18
+ if !status. success ( ) {
19
+ panic ! ( "Command failed!\n output status: `{status}`" ) ;
20
+ }
15
21
}
You can’t perform that action at this time.
0 commit comments