Skip to content

fix(stdin): Provide a Command wrapper #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ assert_cmd = "0.11"
Here's a trivial example:

```rust,no_run
extern crate assert_cmd;
use assert_cmd::Command;

use std::process::Command;
use assert_cmd::prelude::*;

Command::cargo_bin("bin_fixture")
.unwrap()
.assert()
.success();
let mut cmd = Command::cargo_bin("bin_fixture").unwrap();
cmd.assert().success();
```

## Relevant crates
Expand Down
4 changes: 2 additions & 2 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use predicates::str::PredicateStrExt;
use predicates_core;
use predicates_tree::CaseTreeExt;

use crate::cmd::dump_buffer;
use crate::cmd::output_fmt;
use crate::output::dump_buffer;
use crate::output::output_fmt;

/// Assert the state of an [`Output`].
///
Expand Down
22 changes: 16 additions & 6 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,24 @@ where
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError>;
}

impl CommandCargoExt for crate::cmd::Command {
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError> {
crate::cmd::Command::cargo_bin(name)
}
}

impl CommandCargoExt for process::Command {
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError> {
let path = cargo_bin(name);
if path.is_file() {
Ok(process::Command::new(path))
} else {
Err(CargoError::with_cause(NotFoundError { path }))
}
cargo_bin_cmd(name)
}
}

pub(crate) fn cargo_bin_cmd<S: AsRef<str>>(name: S) -> Result<process::Command, CargoError> {
let path = cargo_bin(name);
if path.is_file() {
Ok(process::Command::new(path))
} else {
Err(CargoError::with_cause(NotFoundError { path }))
}
}

Expand Down
Loading