Skip to content

Commit fdf9cd3

Browse files
authored
Merge pull request #85 from epage/10
fix(stdin): Provide a Command wrapper
2 parents 028b0df + d159e87 commit fdf9cd3

File tree

8 files changed

+818
-548
lines changed

8 files changed

+818
-548
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ assert_cmd = "0.11"
2121
Here's a trivial example:
2222

2323
```rust,no_run
24-
extern crate assert_cmd;
24+
use assert_cmd::Command;
2525
26-
use std::process::Command;
27-
use assert_cmd::prelude::*;
28-
29-
Command::cargo_bin("bin_fixture")
30-
.unwrap()
31-
.assert()
32-
.success();
26+
let mut cmd = Command::cargo_bin("bin_fixture").unwrap();
27+
cmd.assert().success();
3328
```
3429

3530
## Relevant crates

src/assert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use predicates::str::PredicateStrExt;
1111
use predicates_core;
1212
use predicates_tree::CaseTreeExt;
1313

14-
use crate::cmd::dump_buffer;
15-
use crate::cmd::output_fmt;
14+
use crate::output::dump_buffer;
15+
use crate::output::output_fmt;
1616

1717
/// Assert the state of an [`Output`].
1818
///

src/cargo.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,24 @@ where
124124
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError>;
125125
}
126126

127+
impl CommandCargoExt for crate::cmd::Command {
128+
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError> {
129+
crate::cmd::Command::cargo_bin(name)
130+
}
131+
}
132+
127133
impl CommandCargoExt for process::Command {
128134
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError> {
129-
let path = cargo_bin(name);
130-
if path.is_file() {
131-
Ok(process::Command::new(path))
132-
} else {
133-
Err(CargoError::with_cause(NotFoundError { path }))
134-
}
135+
cargo_bin_cmd(name)
136+
}
137+
}
138+
139+
pub(crate) fn cargo_bin_cmd<S: AsRef<str>>(name: S) -> Result<process::Command, CargoError> {
140+
let path = cargo_bin(name);
141+
if path.is_file() {
142+
Ok(process::Command::new(path))
143+
} else {
144+
Err(CargoError::with_cause(NotFoundError { path }))
135145
}
136146
}
137147

0 commit comments

Comments
 (0)