]>
Commit | Line | Data |
---|---|---|
54a0048b SL |
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. | |
4 | // | |
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. | |
c30ab7b3 | 10 | // ignore-emscripten Function not implemented. |
54a0048b SL |
11 | |
12 | use std::env; | |
13 | use std::io; | |
14 | use std::io::Write; | |
15 | use std::process::{Command, Stdio}; | |
16 | ||
17 | fn main() { | |
18 | let mut args = env::args(); | |
19 | let me = args.next().unwrap(); | |
20 | let arg = args.next(); | |
21 | match arg.as_ref().map(|s| &s[..]) { | |
22 | None => { | |
23 | let mut s = Command::new(&me) | |
24 | .arg("a1") | |
25 | .stdin(Stdio::piped()) | |
26 | .spawn() | |
27 | .unwrap(); | |
28 | s.stdin.take().unwrap().write_all(b"foo\n").unwrap(); | |
29 | let s = s.wait().unwrap(); | |
30 | assert!(s.success()); | |
31 | } | |
32 | Some("a1") => { | |
33 | let s = Command::new(&me).arg("a2").status().unwrap(); | |
34 | assert!(s.success()); | |
35 | } | |
36 | Some(..) => { | |
37 | let mut s = String::new(); | |
38 | io::stdin().read_line(&mut s).unwrap(); | |
39 | assert_eq!(s, "foo\n"); | |
40 | } | |
41 | } | |
42 | } |