1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-windows - this is a unix-specific test
12 // ignore-pretty issue #37199
13 // ignore-emscripten no processes
15 #![feature(process_exec)]
18 use std::os::unix::process::CommandExt;
19 use std::process::Command;
22 let mut args = env::args();
23 let me = args.next().unwrap();
25 if let Some(arg) = args.next() {
27 "test1" => println!("passed"),
30 let err = Command::new(&me).arg("test1").exec();
31 panic!("failed to spawn: {}", err);
35 Command::new("/path/to/nowhere").exec();
40 Command::new(&me).arg("bad\0").exec();
45 Command::new(&me).current_dir("/path/to/nowhere").exec();
49 _ => panic!("unknown argument: {}", arg),
54 let output = Command::new(&me).arg("exec-test1").output().unwrap();
55 assert!(output.status.success());
56 assert!(output.stderr.is_empty());
57 assert_eq!(output.stdout, b"passed\n");
59 let output = Command::new(&me).arg("exec-test2").output().unwrap();
60 assert!(output.status.success());
61 assert!(output.stderr.is_empty());
62 assert_eq!(output.stdout, b"passed\n");
64 let output = Command::new(&me).arg("exec-test3").output().unwrap();
65 assert!(output.status.success());
66 assert!(output.stderr.is_empty());
67 assert_eq!(output.stdout, b"passed\n");
69 let output = Command::new(&me).arg("exec-test4").output().unwrap();
70 assert!(output.status.success());
71 assert!(output.stderr.is_empty());
72 assert_eq!(output.stdout, b"passed\n");