about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2024-05-29 13:15:10 +0000
committerChris Denton <chris@chrisdenton.dev>2024-05-29 13:15:10 +0000
commit5ec0c002edf05d7a5a3596c26f30ffa258b580bb (patch)
tree8fb99be643d53a5676dc4710c80b49d684884310
parente03f9cb52debfbbc3d995584b572f219b31dad7f (diff)
downloadrust-5ec0c002edf05d7a5a3596c26f30ffa258b580bb.tar.gz
rust-5ec0c002edf05d7a5a3596c26f30ffa258b580bb.zip
Convert windows-binary-no-external-deps to rmake
-rw-r--r--tests/run-make/windows-binary-no-external-deps/Makefile9
-rw-r--r--tests/run-make/windows-binary-no-external-deps/rmake.rs21
2 files changed, 21 insertions, 9 deletions
diff --git a/tests/run-make/windows-binary-no-external-deps/Makefile b/tests/run-make/windows-binary-no-external-deps/Makefile
deleted file mode 100644
index 8960020fed5..00000000000
--- a/tests/run-make/windows-binary-no-external-deps/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-include ../tools.mk
-
-# only-windows
-
-PATH=$(SYSTEMROOT)/system32
-
-all:
-	$(RUSTC) hello.rs
-	$(TMPDIR)/hello.exe
diff --git a/tests/run-make/windows-binary-no-external-deps/rmake.rs b/tests/run-make/windows-binary-no-external-deps/rmake.rs
new file mode 100644
index 00000000000..6704fe04148
--- /dev/null
+++ b/tests/run-make/windows-binary-no-external-deps/rmake.rs
@@ -0,0 +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
+
+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();
+    // 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}`");
+    }
+}