diff --git a/src/lib.rs b/src/lib.rs index bc812729a..774a9fe0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -124,13 +124,11 @@ extern crate tokio_core; extern crate tokio_io; extern crate mio; -use std::ffi::OsStr; use std::io::{self, Read, Write}; -use std::path::Path; use std::process::{self, ExitStatus, Output, Stdio}; use futures::{Future, Poll, IntoFuture}; -use futures::future::{Flatten, FutureResult, Either, ok}; +use futures::future::{Either, ok}; use std::fmt; use tokio_core::reactor::Handle; use tokio_io::io::{read_to_end}; @@ -171,25 +169,6 @@ pub trait CommandExt { /// event loop. fn spawn_async(&mut self, handle: &Handle) -> io::Result; - /// Executes a command as a child process, waiting for it to finish and - /// collecting its exit status. - /// - /// By default, stdin, stdout and stderr are inherited from the parent. - /// - /// The `StatusAsync` future returned will resolve to the `ExitStatus` - /// type in the standard library representing how the process exited. If - /// any input/output handles are set to a pipe then they will be immediately - /// closed after the child is spawned. - /// - /// The `handle` specified must be a handle to a valid event loop, and all - /// I/O this child does will be associated with the specified event loop. - /// - /// If the `StatusAsync` future is dropped before the future resolves, then - /// the child will be killed, if it was spawned. - #[deprecated(note = "use the more flexible `spawn_async2` method instead")] - #[allow(deprecated)] - fn status_async(&mut self, handle: &Handle) -> StatusAsync; - /// Executes a command as a child process, waiting for it to finish and /// collecting its exit status. /// @@ -258,23 +237,6 @@ impl CommandExt for process::Command { Ok(child) } - #[allow(deprecated)] - fn status_async(&mut self, handle: &Handle) -> StatusAsync { - let mut inner = self.spawn_async(handle); - if let Ok(child) = inner.as_mut() { - // Ensure we close any stdio handles so we can't deadlock - // waiting on the child which may be waiting to read/write - // to a pipe we're holding. - child.stdin.take(); - child.stdout.take(); - child.stderr.take(); - } - - StatusAsync { - inner: inner.into_future().flatten(), - } - } - fn status_async2(&mut self, handle: &Handle) -> io::Result { self.spawn_async(handle).map(|mut child| { // Ensure we close any stdio handles so we can't deadlock @@ -476,29 +438,6 @@ impl Future for WaitWithOutput { } } -/// Future returned by the `CommandExt::status_async` method. -/// -/// This future is used to conveniently spawn a child and simply wait for its -/// exit status. This future will resolves to the `ExitStatus` type in the -/// standard library. -#[must_use = "futures do nothing unless polled"] -#[deprecated(note = "use the more flexible `SpawnAsync2` adapter instead")] -#[allow(deprecated)] -#[derive(Debug)] -pub struct StatusAsync { - inner: Flatten>, -} - -#[allow(deprecated)] -impl Future for StatusAsync { - type Item = ExitStatus; - type Error = io::Error; - - fn poll(&mut self) -> Poll { - self.inner.poll() - } -} - /// Future returned by the `CommandExt::status_async2` method. /// /// This future is used to conveniently spawn a child and simply wait for its @@ -611,107 +550,3 @@ impl Read for ChildStderr { impl AsyncRead for ChildStderr { } - -// deprecated from 0.1.0 - -#[deprecated(note = "use std::process::Command instead")] -#[allow(deprecated, missing_docs)] -#[allow(deprecated, missing_debug_implementations, missing_docs)] -#[doc(hidden)] -pub struct Command { - inner: process::Command, - #[allow(dead_code)] - handle: Handle, -} - -#[deprecated(note = "use std::process::Command instead")] -#[allow(deprecated, missing_debug_implementations, missing_docs)] -#[doc(hidden)] -pub struct Spawn { - inner: Box>, -} - -#[deprecated(note = "use std::process::Command instead")] -#[allow(deprecated, missing_docs)] -#[doc(hidden)] -impl Command { - pub fn new>(exe: T, handle: &Handle) -> Command { - Command::_new(exe.as_ref(), handle) - } - - fn _new(exe: &OsStr, handle: &Handle) -> Command { - Command { - inner: process::Command::new(exe), - handle: handle.clone(), - } - } - - pub fn arg>(&mut self, arg: S) -> &mut Command { - self._arg(arg.as_ref()) - } - - fn _arg(&mut self, arg: &OsStr) -> &mut Command { - self.inner.arg(arg); - self - } - - pub fn args>(&mut self, args: &[S]) -> &mut Command { - for arg in args { - self._arg(arg.as_ref()); - } - self - } - - pub fn env(&mut self, key: K, val: V) -> &mut Command - where K: AsRef, V: AsRef - { - self._env(key.as_ref(), val.as_ref()) - } - - fn _env(&mut self, key: &OsStr, val: &OsStr) -> &mut Command { - self.inner.env(key, val); - self - } - - pub fn env_remove>(&mut self, key: K) -> &mut Command { - self._env_remove(key.as_ref()) - } - - fn _env_remove(&mut self, key: &OsStr) -> &mut Command { - self.inner.env_remove(key); - self - } - - pub fn env_clear(&mut self) -> &mut Command { - self.inner.env_clear(); - self - } - - pub fn current_dir>(&mut self, dir: P) -> &mut Command { - self._current_dir(dir.as_ref()) - } - - fn _current_dir(&mut self, dir: &Path) -> &mut Command { - self.inner.current_dir(dir); - self - } - - pub fn spawn(mut self) -> Spawn { - Spawn { - inner: Box::new(self.inner.spawn_async(&self.handle).into_future()), - } - } -} - -#[deprecated(note = "use std::process::Command instead")] -#[allow(deprecated)] -#[doc(hidden)] -impl Future for Spawn { - type Item = Child; - type Error = io::Error; - - fn poll(&mut self) -> Poll { - self.inner.poll() - } -} - diff --git a/tests/stdio.rs b/tests/stdio.rs index 401e8082a..25e9fcd34 100644 --- a/tests/stdio.rs +++ b/tests/stdio.rs @@ -119,25 +119,6 @@ fn wait_with_output_captures() { assert_eq!(output.stderr.len(), 0); } -#[allow(deprecated)] -#[test] -fn status_closes_any_pipes() { - let mut core = Core::new().unwrap(); - - // Cat will open a pipe between the parent and child. - // If `status_async` doesn't ensure the handles are closed, - // we would end up blocking forever (and time out). - let child = cat().status_async(&core.handle()); - let timeout = Timeout::new(Duration::from_secs(1), &core.handle()) - .expect("timeout registration failed") - .map(|()| panic!("time out exceeded! did we get stuck waiting on the child?")); - - match core.run(child.select(timeout)) { - Ok((status, _)) => assert!(status.success()), - Err(_) => panic!("failed to run futures"), - } -} - #[test] fn status2_closes_any_pipes() { let mut core = Core::new().unwrap();