1 // Copyright 2014 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.
13 use std::io::process::{Command, ProcessOutput};
16 use std::rt::unwind::try;
18 local_data_key!(foo: int)
21 fn start(argc: int, argv: *const *const u8) -> int {
24 match **argv.offset(1) {
27 3 => assert!(try(|| {}).is_ok()),
28 4 => assert!(try(|| fail!()).is_err()),
29 5 => assert!(try(|| spawn(proc() {})).is_err()),
30 6 => assert!(Command::new("test").spawn().is_err()),
31 7 => assert!(foo.get().is_none()),
32 8 => assert!(try(|| { foo.replace(Some(3)); }).is_err()),
39 native::start(argc, argv, main)
43 let args = os::args();
44 let me = args.get(0).as_slice();
46 pass(Command::new(me).arg(&[1u8]).output().unwrap());
47 pass(Command::new(me).arg(&[2u8]).output().unwrap());
48 pass(Command::new(me).arg(&[3u8]).output().unwrap());
49 pass(Command::new(me).arg(&[4u8]).output().unwrap());
50 pass(Command::new(me).arg(&[5u8]).output().unwrap());
51 pass(Command::new(me).arg(&[6u8]).output().unwrap());
52 pass(Command::new(me).arg(&[7u8]).output().unwrap());
53 pass(Command::new(me).arg(&[8u8]).output().unwrap());
56 fn pass(output: ProcessOutput) {
57 if !output.status.success() {
58 println!("{}", str::from_utf8(output.output.as_slice()));
59 println!("{}", str::from_utf8(output.error.as_slice()));