]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/command-exec.rs
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
14 #![feature(process_exec)]
17 use std
::os
::unix
::process
::CommandExt
;
18 use std
::process
::Command
;
21 let mut args
= env
::args();
22 let me
= args
.next().unwrap();
24 if let Some(arg
) = args
.next() {
26 "test1" => println
!("passed"),
29 let err
= Command
::new(&me
).arg("test1").exec();
30 panic
!("failed to spawn: {}", err
);
34 Command
::new("/path/to/nowhere").exec();
39 Command
::new(&me
).arg("bad\0").exec();
44 Command
::new(&me
).current_dir("/path/to/nowhere").exec();
48 _
=> panic
!("unknown argument: {}", arg
),
53 let output
= Command
::new(&me
).arg("exec-test1").output().unwrap();
54 assert
!(output
.status
.success());
55 assert
!(output
.stderr
.is_empty());
56 assert_eq
!(output
.stdout
, b
"passed\n");
58 let output
= Command
::new(&me
).arg("exec-test2").output().unwrap();
59 assert
!(output
.status
.success());
60 assert
!(output
.stderr
.is_empty());
61 assert_eq
!(output
.stdout
, b
"passed\n");
63 let output
= Command
::new(&me
).arg("exec-test3").output().unwrap();
64 assert
!(output
.status
.success());
65 assert
!(output
.stderr
.is_empty());
66 assert_eq
!(output
.stdout
, b
"passed\n");
68 let output
= Command
::new(&me
).arg("exec-test4").output().unwrap();
69 assert
!(output
.status
.success());
70 assert
!(output
.stderr
.is_empty());
71 assert_eq
!(output
.stdout
, b
"passed\n");