@@ -90,7 +90,7 @@ mod diff;
9090#[ derive( Debug ) ]
9191pub struct Assert {
9292 cmd : Vec < String > ,
93- expect_success : bool ,
93+ expect_success : Option < bool > ,
9494 expect_exit_code : Option < i32 > ,
9595 expect_stdout : Option < OutputAssertion > ,
9696 expect_stderr : Option < OutputAssertion > ,
@@ -134,7 +134,7 @@ impl std::default::Default for Assert {
134134 Assert {
135135 cmd : vec ! [ "cargo" , "run" , "--" ]
136136 . into_iter ( ) . map ( String :: from) . collect ( ) ,
137- expect_success : true ,
137+ expect_success : None ,
138138 expect_exit_code : None ,
139139 expect_stdout : None ,
140140 expect_stderr : None ,
@@ -216,8 +216,6 @@ impl Assert {
216216
217217 /// Expect the command to be executed successfully.
218218 ///
219- /// Note: This is already set by default, so you only need this for explicitness.
220- ///
221219 /// # Examples
222220 ///
223221 /// ```rust
@@ -228,7 +226,8 @@ impl Assert {
228226 /// .unwrap();
229227 /// ```
230228 pub fn succeeds ( mut self ) -> Self {
231- self . expect_success = true ;
229+ self . expect_exit_code = None ;
230+ self . expect_success = Some ( true ) ;
232231 self
233232 }
234233
@@ -247,7 +246,7 @@ impl Assert {
247246 /// .unwrap();
248247 /// ```
249248 pub fn fails ( mut self ) -> Self {
250- self . expect_success = false ;
249+ self . expect_success = Some ( false ) ;
251250 self
252251 }
253252
@@ -263,7 +262,7 @@ impl Assert {
263262 /// .unwrap();
264263 /// ```
265264 pub fn fails_with ( mut self , expect_exit_code : i32 ) -> Self {
266- self . expect_success = false ;
265+ self . expect_success = Some ( false ) ;
267266 self . expect_exit_code = Some ( expect_exit_code) ;
268267 self
269268 }
@@ -366,11 +365,13 @@ impl Assert {
366365 let output = command. output ( ) ?;
367366
368367
369- if self . expect_success != output. status . success ( ) {
370- bail ! ( ErrorKind :: StatusMismatch (
371- self . cmd. clone( ) ,
372- self . expect_success. clone( ) ,
373- ) ) ;
368+ if let Some ( expect_success) = self . expect_success {
369+ if expect_success != output. status . success ( ) {
370+ bail ! ( ErrorKind :: StatusMismatch (
371+ self . cmd. clone( ) ,
372+ expect_success,
373+ ) ) ;
374+ }
374375 }
375376
376377 if self . expect_exit_code . is_some ( ) &&
0 commit comments