Convert run-make/windows-spawn to rmake

This commit is contained in:
Chris Denton 2024-05-29 13:12:45 +00:00
parent f08e00f3d5
commit e463f6fd0b
No known key found for this signature in database
GPG key ID: 713472F2F45627DE
3 changed files with 21 additions and 14 deletions

View file

@ -1,8 +0,0 @@
include ../tools.mk
# only-windows
all:
$(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs
$(RUSTC) spawn.rs
$(TMPDIR)/spawn.exe

View file

@ -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");
}

View file

@ -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
)
}