about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-09-27 16:28:14 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-10-01 17:04:17 -0700
commit02cbfce0b3a2962a5faf6065bd652ea165a666ca (patch)
treec05a68202b2047d4540306916fb9c0a970ef0b55 /src
parent67394f20eb0176828bc65f5caf6f4044994d9fb0 (diff)
downloadrust-02cbfce0b3a2962a5faf6065bd652ea165a666ca.tar.gz
rust-02cbfce0b3a2962a5faf6065bd652ea165a666ca.zip
Move the rt::io::process tests to run-pass
Closes #9341
Diffstat (limited to 'src')
-rw-r--r--src/libstd/rt/io/process.rs144
-rw-r--r--src/test/run-pass/rtio-processes.rs156
2 files changed, 158 insertions, 142 deletions
diff --git a/src/libstd/rt/io/process.rs b/src/libstd/rt/io/process.rs
index 91efd93026c..b2dbd8ee1f4 100644
--- a/src/libstd/rt/io/process.rs
+++ b/src/libstd/rt/io/process.rs
@@ -140,145 +140,5 @@ impl Drop for Process {
     }
 }
 
-#[cfg(test)]
-mod tests {
-    use prelude::*;
-    use super::*;
-
-    use rt::io::{Reader, Writer};
-    use rt::io::pipe::*;
-    use str;
-
-    #[test]
-    #[cfg(unix, not(android))]
-    #[ignore] // FIXME(#9341)
-    fn smoke() {
-        let io = ~[];
-        let args = ProcessConfig {
-            program: "/bin/sh",
-            args: [~"-c", ~"true"],
-            env: None,
-            cwd: None,
-            io: io,
-        };
-        let p = Process::new(args);
-        assert!(p.is_some());
-        let mut p = p.unwrap();
-        assert_eq!(p.wait(), 0);
-    }
-
-    #[test]
-    #[cfg(unix, not(android))]
-    #[ignore] // FIXME(#9341)
-    fn smoke_failure() {
-        let io = ~[];
-        let args = ProcessConfig {
-            program: "if-this-is-a-binary-then-the-world-has-ended",
-            args: [],
-            env: None,
-            cwd: None,
-            io: io,
-        };
-        let p = Process::new(args);
-        assert!(p.is_some());
-        let mut p = p.unwrap();
-        assert!(p.wait() != 0);
-    }
-
-    #[test]
-    #[cfg(unix, not(android))]
-    #[ignore] // FIXME(#9341)
-    fn exit_reported_right() {
-        let io = ~[];
-        let args = ProcessConfig {
-            program: "/bin/sh",
-            args: [~"-c", ~"exit 1"],
-            env: None,
-            cwd: None,
-            io: io,
-        };
-        let p = Process::new(args);
-        assert!(p.is_some());
-        let mut p = p.unwrap();
-        assert_eq!(p.wait(), 1);
-    }
-
-    fn read_all(input: &mut Reader) -> ~str {
-        let mut ret = ~"";
-        let mut buf = [0, ..1024];
-        loop {
-            match input.read(buf) {
-                None | Some(0) => { break }
-                Some(n) => { ret = ret + str::from_utf8(buf.slice_to(n)); }
-            }
-        }
-        return ret;
-    }
-
-    fn run_output(args: ProcessConfig) -> ~str {
-        let p = Process::new(args);
-        assert!(p.is_some());
-        let mut p = p.unwrap();
-        assert!(p.io[0].is_none());
-        assert!(p.io[1].is_some());
-        let ret = read_all(p.io[1].get_mut_ref() as &mut Reader);
-        assert_eq!(p.wait(), 0);
-        return ret;
-    }
-
-    #[test]
-    #[cfg(unix, not(android))]
-    #[ignore] // FIXME(#9341)
-    fn stdout_works() {
-        let pipe = PipeStream::new().unwrap();
-        let io = ~[Ignored, CreatePipe(pipe, false, true)];
-        let args = ProcessConfig {
-            program: "/bin/sh",
-            args: [~"-c", ~"echo foobar"],
-            env: None,
-            cwd: None,
-            io: io,
-        };
-        assert_eq!(run_output(args), ~"foobar\n");
-    }
-
-    #[test]
-    #[cfg(unix, not(android))]
-    #[ignore] // FIXME(#9341)
-    fn set_cwd_works() {
-        let pipe = PipeStream::new().unwrap();
-        let io = ~[Ignored, CreatePipe(pipe, false, true)];
-        let cwd = Some("/");
-        let args = ProcessConfig {
-            program: "/bin/sh",
-            args: [~"-c", ~"pwd"],
-            env: None,
-            cwd: cwd,
-            io: io,
-        };
-        assert_eq!(run_output(args), ~"/\n");
-    }
-
-    #[test]
-    #[cfg(unix, not(android))]
-    #[ignore] // FIXME(#9341)
-    fn stdin_works() {
-        let input = PipeStream::new().unwrap();
-        let output = PipeStream::new().unwrap();
-        let io = ~[CreatePipe(input, true, false),
-                   CreatePipe(output, false, true)];
-        let args = ProcessConfig {
-            program: "/bin/sh",
-            args: [~"-c", ~"read line; echo $line"],
-            env: None,
-            cwd: None,
-            io: io,
-        };
-        let mut p = Process::new(args).expect("didn't create a proces?!");
-        p.io[0].get_mut_ref().write("foobar".as_bytes());
-        p.io[0] = None; // close stdin;
-        let out = read_all(p.io[1].get_mut_ref() as &mut Reader);
-        assert_eq!(p.wait(), 0);
-        assert_eq!(out, ~"foobar\n");
-    }
-}
+// Tests for this module can be found in the rtio-processes run-pass test, along
+// with the justification for why it's not located here.
diff --git a/src/test/run-pass/rtio-processes.rs b/src/test/run-pass/rtio-processes.rs
new file mode 100644
index 00000000000..e4d3b0ed872
--- /dev/null
+++ b/src/test/run-pass/rtio-processes.rs
@@ -0,0 +1,156 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: --test
+// xfail-fast
+
+// In the current state of affairs, libuv registers a SIGCHLD handler when a
+// process is spawned through it. This is not done with a SA_RESTART flag,
+// meaning that all of our syscalls run the risk of returning EINTR. This error
+// is not correctly handled in the majority of std::io, so these can't run with
+// the main body of tests there.
+//
+// That being said, libuv correctly handles EINTR completely, so these tests
+// themselves are safe against that. Currently the test runner may run into this
+// problem, but it's less likely than a whole suite of tests...
+//
+// See #9341
+
+use std::rt::io::process::*;
+use std::rt::io::{Reader, Writer};
+use std::rt::io::pipe::*;
+use std::str;
+
+#[test]
+#[cfg(unix, not(android))]
+fn smoke() {
+    let io = ~[];
+    let args = ProcessConfig {
+        program: "/bin/sh",
+        args: [~"-c", ~"true"],
+        env: None,
+        cwd: None,
+        io: io,
+    };
+    let p = Process::new(args);
+    assert!(p.is_some());
+    let mut p = p.unwrap();
+    assert_eq!(p.wait(), 0);
+}
+
+#[test]
+#[cfg(unix, not(android))]
+fn smoke_failure() {
+    let io = ~[];
+    let args = ProcessConfig {
+        program: "if-this-is-a-binary-then-the-world-has-ended",
+        args: [],
+        env: None,
+        cwd: None,
+        io: io,
+    };
+    let p = Process::new(args);
+    assert!(p.is_some());
+    let mut p = p.unwrap();
+    assert!(p.wait() != 0);
+}
+
+#[test]
+#[cfg(unix, not(android))]
+fn exit_reported_right() {
+    let io = ~[];
+    let args = ProcessConfig {
+        program: "/bin/sh",
+        args: [~"-c", ~"exit 1"],
+        env: None,
+        cwd: None,
+        io: io,
+    };
+    let p = Process::new(args);
+    assert!(p.is_some());
+    let mut p = p.unwrap();
+    assert_eq!(p.wait(), 1);
+}
+
+fn read_all(input: &mut Reader) -> ~str {
+    let mut ret = ~"";
+    let mut buf = [0, ..1024];
+    loop {
+        match input.read(buf) {
+            None | Some(0) => { break }
+            Some(n) => { ret = ret + str::from_utf8(buf.slice_to(n)); }
+        }
+    }
+    return ret;
+}
+
+fn run_output(args: ProcessConfig) -> ~str {
+    let p = Process::new(args);
+    assert!(p.is_some());
+    let mut p = p.unwrap();
+    assert!(p.io[0].is_none());
+    assert!(p.io[1].is_some());
+    let ret = read_all(p.io[1].get_mut_ref() as &mut Reader);
+    assert_eq!(p.wait(), 0);
+    return ret;
+}
+
+#[test]
+#[cfg(unix, not(android))]
+fn stdout_works() {
+    let pipe = PipeStream::new().unwrap();
+    let io = ~[Ignored, CreatePipe(pipe, false, true)];
+    let args = ProcessConfig {
+        program: "/bin/sh",
+        args: [~"-c", ~"echo foobar"],
+        env: None,
+        cwd: None,
+        io: io,
+    };
+    assert_eq!(run_output(args), ~"foobar\n");
+}
+
+#[test]
+#[cfg(unix, not(android))]
+fn set_cwd_works() {
+    let pipe = PipeStream::new().unwrap();
+    let io = ~[Ignored, CreatePipe(pipe, false, true)];
+    let cwd = Some("/");
+    let args = ProcessConfig {
+        program: "/bin/sh",
+        args: [~"-c", ~"pwd"],
+        env: None,
+        cwd: cwd,
+        io: io,
+    };
+    assert_eq!(run_output(args), ~"/\n");
+}
+
+#[test]
+#[cfg(unix, not(android))]
+fn stdin_works() {
+    let input = PipeStream::new().unwrap();
+    let output = PipeStream::new().unwrap();
+    let io = ~[CreatePipe(input, true, false),
+               CreatePipe(output, false, true)];
+    let args = ProcessConfig {
+        program: "/bin/sh",
+        args: [~"-c", ~"read line; echo $line"],
+        env: None,
+        cwd: None,
+        io: io,
+    };
+    let mut p = Process::new(args).expect("didn't create a proces?!");
+    p.io[0].get_mut_ref().write("foobar".as_bytes());
+    p.io[0] = None; // close stdin;
+    let out = read_all(p.io[1].get_mut_ref() as &mut Reader);
+    assert_eq!(p.wait(), 0);
+    assert_eq!(out, ~"foobar\n");
+}