]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/process-status-inherits-stdin.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / run-pass / process-status-inherits-stdin.rs
CommitLineData
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
12use std::env;
13use std::io;
14use std::io::Write;
15use std::process::{Command, Stdio};
16
17fn 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}