diff options
| author | Chris Denton <chris@chrisdenton.dev> | 2024-05-29 13:12:45 +0000 |
|---|---|---|
| committer | Chris Denton <chris@chrisdenton.dev> | 2024-05-29 13:12:45 +0000 |
| commit | e463f6fd0bbd7d22bb81cd1ab769eeeb21d9e91d (patch) | |
| tree | 1603f8efe09c12a0a0ca919f109e888fe5fb6682 | |
| parent | f08e00f3d56645c9bbd4d2ebfbabe257b56b837b (diff) | |
| download | rust-e463f6fd0bbd7d22bb81cd1ab769eeeb21d9e91d.tar.gz rust-e463f6fd0bbd7d22bb81cd1ab769eeeb21d9e91d.zip | |
Convert run-make/windows-spawn to rmake
| -rw-r--r-- | tests/run-make/windows-spawn/Makefile | 8 | ||||
| -rw-r--r-- | tests/run-make/windows-spawn/rmake.rs | 17 | ||||
| -rw-r--r-- | tests/run-make/windows-spawn/spawn.rs | 10 |
3 files changed, 21 insertions, 14 deletions
diff --git a/tests/run-make/windows-spawn/Makefile b/tests/run-make/windows-spawn/Makefile deleted file mode 100644 index b6cdb169bab..00000000000 --- a/tests/run-make/windows-spawn/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../tools.mk - -# only-windows - -all: - $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs - $(RUSTC) spawn.rs - $(TMPDIR)/spawn.exe diff --git a/tests/run-make/windows-spawn/rmake.rs b/tests/run-make/windows-spawn/rmake.rs new file mode 100644 index 00000000000..fb9cf1e2149 --- /dev/null +++ b/tests/run-make/windows-spawn/rmake.rs @@ -0,0 +1,17 @@ +//@ only-windows + +use run_make_support::{run, rustc, tmp_dir}; + +// On Windows `Command` uses `CreateProcessW` to run a new process. +// However, in the past std used to not pass in the application name, leaving +// `CreateProcessW` to use heuristics to guess the intended name from the +// command line string. Sometimes this could go very wrong. +// E.g. in Rust 1.0 `Command::new("foo").arg("bar").spawn()` will try to launch +// `foo bar.exe` if foo.exe does not exist. Which is clearly not desired. + +fn main() { + let out_dir = tmp_dir(); + rustc().input("hello.rs").output(out_dir.join("hopefullydoesntexist bar.exe")).run(); + rustc().input("spawn.rs").run(); + run("spawn"); +} diff --git a/tests/run-make/windows-spawn/spawn.rs b/tests/run-make/windows-spawn/spawn.rs index c34da3d5fde..a9e86d1577e 100644 --- a/tests/run-make/windows-spawn/spawn.rs +++ b/tests/run-make/windows-spawn/spawn.rs @@ -3,10 +3,8 @@ use std::process::Command; fn main() { // Make sure it doesn't try to run "hopefullydoesntexist bar.exe". - assert_eq!(Command::new("hopefullydoesntexist") - .arg("bar") - .spawn() - .unwrap_err() - .kind(), - ErrorKind::NotFound); + assert_eq!( + Command::new("hopefullydoesntexist").arg("bar").spawn().unwrap_err().kind(), + ErrorKind::NotFound + ) } |
