2024-05-29 08:15:10 -05:00
|
|
|
//! Ensure that we aren't relying on any non-system DLLs when running
|
|
|
|
//! a "hello world" application by setting `PATH` to `C:\Windows\System32`.
|
|
|
|
//@ only-windows
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::process::Command;
|
|
|
|
|
2024-06-08 08:40:07 -05:00
|
|
|
use run_make_support::{cwd, env_var, rustc};
|
2024-07-28 17:13:50 -05:00
|
|
|
|
2024-05-29 08:15:10 -05:00
|
|
|
fn main() {
|
|
|
|
rustc().input("hello.rs").run();
|
|
|
|
|
2024-06-03 03:28:52 -05:00
|
|
|
let windows_dir = env_var("SystemRoot");
|
2024-05-29 08:15:10 -05:00
|
|
|
let system32: PathBuf = [&windows_dir, "System32"].iter().collect();
|
|
|
|
// Note: This does not use the support wrappers so that we can precisely control the PATH
|
2024-06-08 08:40:07 -05:00
|
|
|
let exe = cwd().join("hello.exe");
|
2024-05-29 08:15:10 -05:00
|
|
|
let status = Command::new(exe).env("PATH", &system32).spawn().unwrap().wait().unwrap();
|
|
|
|
if !status.success() {
|
|
|
|
panic!("Command failed!\noutput status: `{status}`");
|
|
|
|
}
|
|
|
|
}
|