Skip to content

Commit

Permalink
Fixup windows-binary-no-external-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed May 29, 2024
1 parent ad5dce5 commit 0034ce5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/run-make/windows-binary-no-external-deps/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
//! 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

// Ensure that we aren't relying on any non-system DLLs when compiling and running
// a "hello world" application by setting `PATH` to `C:\Windows\System32`.

use run_make_support::{run, rustc};
use run_make_support::{rustc, tmp_dir};
use std::env;
use std::path::PathBuf;
use std::process::Command;

fn main() {
rustc().input("hello.rs").run();

let windows_dir = env::var("SystemRoot").unwrap();
let system32: PathBuf = [&windows_dir, "System32"].iter().collect();
rustc().input("hello.rs").env("PATH", system32).run();
run("hello");
// Note: This does not use the support wrappers so that we can precisely control the PATH
let exe = tmp_dir().join("hello.exe");
let status = Command::new(exe).env("PATH", &system32).spawn().unwrap().wait().unwrap();
if !status.success() {
panic!("Command failed!\noutput status: `{status}`");
}
}

0 comments on commit 0034ce5

Please sign in to comment.