]>
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 #![allow(stable_features)]
12 // ignore-windows - this is a unix-specific test
13 // ignore-pretty issue #37199
14 // ignore-cloudabi no processes
15 // ignore-emscripten no processes
17 #![feature(process_exec)]
20 use std
::os
::unix
::process
::CommandExt
;
21 use std
::process
::Command
;
24 let mut args
= env
::args();
25 let me
= args
.next().unwrap();
27 if let Some(arg
) = args
.next() {
29 "test1" => println
!("passed"),
32 let err
= Command
::new(&me
).arg("test1").exec();
33 panic
!("failed to spawn: {}", err
);
37 Command
::new("/path/to/nowhere").exec();
42 Command
::new(&me
).arg("bad\0").exec();
47 Command
::new(&me
).current_dir("/path/to/nowhere").exec();
51 _
=> panic
!("unknown argument: {}", arg
),
56 let output
= Command
::new(&me
).arg("exec-test1").output().unwrap();
57 assert
!(output
.status
.success());
58 assert
!(output
.stderr
.is_empty());
59 assert_eq
!(output
.stdout
, b
"passed\n");
61 let output
= Command
::new(&me
).arg("exec-test2").output().unwrap();
62 assert
!(output
.status
.success());
63 assert
!(output
.stderr
.is_empty());
64 assert_eq
!(output
.stdout
, b
"passed\n");
66 let output
= Command
::new(&me
).arg("exec-test3").output().unwrap();
67 assert
!(output
.status
.success());
68 assert
!(output
.stderr
.is_empty());
69 assert_eq
!(output
.stdout
, b
"passed\n");
71 let output
= Command
::new(&me
).arg("exec-test4").output().unwrap();
72 assert
!(output
.status
.success());
73 assert
!(output
.stderr
.is_empty());
74 assert_eq
!(output
.stdout
, b
"passed\n");