Skip to content

Commit f7d6e8a

Browse files
author
Ed Page
committed
fix(assert): Be explicit about spawn failure
Users had to infer the reason for the panic based on the location. Instead, we should tell them what failed so they can more quickly get up and going on fixing it. Fixes #109
1 parent 8331567 commit f7d6e8a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88

99
## [Unreleased] - ReleaseDate
1010

11+
#### Fixes
12+
13+
- Be explicit about spawn failure (closes [#109](https://github.com/assert-rs/assert_cmd/issues/109)).
14+
1115
## 1.0.1 (2020-03-30)
1216

1317
#### Fixes

src/assert.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ impl OutputAssertExt for process::Output {
5757

5858
impl<'c> OutputAssertExt for &'c mut process::Command {
5959
fn assert(self) -> Assert {
60-
let output = self.output().unwrap();
60+
let output = match self.output() {
61+
Ok(output) => output,
62+
Err(err) => {
63+
panic!("Failed to spawn {:?}: {}", self, err);
64+
}
65+
};
6166
Assert::new(output).append_context("command", format!("{:?}", self))
6267
}
6368
}

0 commit comments

Comments
 (0)