rust/tests/run-make/windows-binary-no-external-deps/rmake.rs
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00

22 lines
752 B
Rust

//! 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;
use run_make_support::{cwd, env_var, rustc};
fn main() {
rustc().input("hello.rs").run();
let windows_dir = env_var("SystemRoot");
let system32: PathBuf = [&windows_dir, "System32"].iter().collect();
// Note: This does not use the support wrappers so that we can precisely control the PATH
let exe = cwd().join("hello.exe");
let status = Command::new(exe).env("PATH", &system32).spawn().unwrap().wait().unwrap();
if !status.success() {
panic!("Command failed!\noutput status: `{status}`");
}
}