From 02955f508e577d104bcd0f6b8b92e7a7b4657708 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Mon, 5 Jun 2017 17:57:32 +0100 Subject: [PATCH] Add run-make test for Command::spawn on Windows Make sure args aren't interpreted as part of the program name. --- src/test/run-make/windows-spawn/Makefile | 14 ++++++++++++++ src/test/run-make/windows-spawn/hello.rs | 13 +++++++++++++ src/test/run-make/windows-spawn/spawn.rs | 22 ++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/test/run-make/windows-spawn/Makefile create mode 100644 src/test/run-make/windows-spawn/hello.rs create mode 100644 src/test/run-make/windows-spawn/spawn.rs diff --git a/src/test/run-make/windows-spawn/Makefile b/src/test/run-make/windows-spawn/Makefile new file mode 100644 index 0000000000000..f0d4242260fb5 --- /dev/null +++ b/src/test/run-make/windows-spawn/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +ifdef IS_WINDOWS + +all: + $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs + $(RUSTC) spawn.rs + $(TMPDIR)/spawn.exe + +else + +all: + +endif diff --git a/src/test/run-make/windows-spawn/hello.rs b/src/test/run-make/windows-spawn/hello.rs new file mode 100644 index 0000000000000..b177f41941d1b --- /dev/null +++ b/src/test/run-make/windows-spawn/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello World!"); +} diff --git a/src/test/run-make/windows-spawn/spawn.rs b/src/test/run-make/windows-spawn/spawn.rs new file mode 100644 index 0000000000000..2913cbe2260c1 --- /dev/null +++ b/src/test/run-make/windows-spawn/spawn.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::io::ErrorKind; +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); +}