diff options
| author | Lukas Pustina <lukas.pustina@centerdevice.com> | 2016-03-21 14:17:17 +0100 |
|---|---|---|
| committer | Lukas Pustina <lukas.pustina@centerdevice.com> | 2016-03-21 14:17:17 +0100 |
| commit | 0dd5f67f4af2f071fa435dc0487d3678d3cf40dd (patch) | |
| tree | e03b270b919b6adad3133b59daf7db85214fabcb /src/libstd/process.rs | |
| parent | 45517947ba9a69260e5b3f4fe54a9aa21ed703eb (diff) | |
| download | rust-0dd5f67f4af2f071fa435dc0487d3678d3cf40dd.tar.gz rust-0dd5f67f4af2f071fa435dc0487d3678d3cf40dd.zip | |
Adjusts all rust doc test to use `expect` and `should_panic`
- All Rust Doc tests execute the same command `/bin/cat file.txt` which `should_panic` on all platforms consistently, because either `/bin/cat` or `file.txt` do not exist.
Diffstat (limited to 'src/libstd/process.rs')
| -rw-r--r-- | src/libstd/process.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 1b6993f1940..d58e8ebab58 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -38,10 +38,10 @@ use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; /// let mut child = Command::new("/bin/cat") /// .arg("file.txt") /// .spawn() -/// .unwrap_or_else(|e| { panic!("failed to execute child: {}", e) }); +/// .expect("failed to execute child"); /// /// let ecode = child.wait() -/// .unwrap_or_else(|e| { panic!("failed to wait on child: {}", e) }); +/// .expect("failed to wait on child"); /// /// assert!(ecode.success()); /// ``` @@ -195,7 +195,8 @@ impl FromInner<AnonPipe> for ChildStderr { /// .arg("-c") /// .arg("echo hello") /// .output() -/// .unwrap_or_else(|e| { panic!("failed to execute process: {}", e) }); +/// .expect("failed to execute proces"); +/// /// let hello = output.stdout; /// ``` #[stable(feature = "process", since = "1.0.0")] @@ -305,11 +306,10 @@ impl Command { /// /// # Examples /// - /// ``` + /// ```should_panic /// use std::process::Command; - /// let output = Command::new("cat").arg("foo.txt").output().unwrap_or_else(|e| { - /// panic!("failed to execute process: {}", e) - /// }); + /// let output = Command::new("/bin/cat").arg("file.txt").output() + /// .expect("failed to execute process"); /// /// println!("status: {}", output.status); /// println!("stdout: {}", String::from_utf8_lossy(&output.stdout)); @@ -328,12 +328,11 @@ impl Command { /// /// # Examples /// - /// ``` + /// ```should_panic /// use std::process::Command; /// - /// let status = Command::new("ls").status().unwrap_or_else(|e| { - /// panic!("failed to execute process: {}", e) - /// }); + /// let status = Command::new("/bin/cat").arg("file.txt").status() + /// .expect("failed to execute process"); /// /// println!("process exited with: {}", status); /// ``` @@ -511,13 +510,13 @@ impl Child { /// use std::process::{Command, Stdio}; /// /// let mut child = Command::new("/bin/cat") - /// .stdout(Stdio::piped()) /// .arg("file.txt") + /// .stdout(Stdio::piped()) /// .spawn() - /// .unwrap_or_else(|e| { panic!("failed to execute child: {}", e) }); + /// .expect("failed to execute child"); /// /// let ecode = child.wait_with_output() - /// .unwrap_or_else(|e| { panic!("failed to wait on child: {}", e) }); + /// .expect("failed to wait on child"); /// /// assert!(ecode.success()); /// ``` |
