@@ -90,7 +90,7 @@ mod diff;
90
90
#[ derive( Debug ) ]
91
91
pub struct Assert {
92
92
cmd : Vec < String > ,
93
- expect_success : bool ,
93
+ expect_success : Option < bool > ,
94
94
expect_exit_code : Option < i32 > ,
95
95
expect_stdout : Option < OutputAssertion > ,
96
96
expect_stderr : Option < OutputAssertion > ,
@@ -134,7 +134,7 @@ impl std::default::Default for Assert {
134
134
Assert {
135
135
cmd : vec ! [ "cargo" , "run" , "--" ]
136
136
. into_iter ( ) . map ( String :: from) . collect ( ) ,
137
- expect_success : true ,
137
+ expect_success : None ,
138
138
expect_exit_code : None ,
139
139
expect_stdout : None ,
140
140
expect_stderr : None ,
@@ -216,8 +216,6 @@ impl Assert {
216
216
217
217
/// Expect the command to be executed successfully.
218
218
///
219
- /// Note: This is already set by default, so you only need this for explicitness.
220
- ///
221
219
/// # Examples
222
220
///
223
221
/// ```rust
@@ -228,7 +226,8 @@ impl Assert {
228
226
/// .unwrap();
229
227
/// ```
230
228
pub fn succeeds ( mut self ) -> Self {
231
- self . expect_success = true ;
229
+ self . expect_exit_code = None ;
230
+ self . expect_success = Some ( true ) ;
232
231
self
233
232
}
234
233
@@ -247,7 +246,7 @@ impl Assert {
247
246
/// .unwrap();
248
247
/// ```
249
248
pub fn fails ( mut self ) -> Self {
250
- self . expect_success = false ;
249
+ self . expect_success = Some ( false ) ;
251
250
self
252
251
}
253
252
@@ -263,7 +262,7 @@ impl Assert {
263
262
/// .unwrap();
264
263
/// ```
265
264
pub fn fails_with ( mut self , expect_exit_code : i32 ) -> Self {
266
- self . expect_success = false ;
265
+ self . expect_success = Some ( false ) ;
267
266
self . expect_exit_code = Some ( expect_exit_code) ;
268
267
self
269
268
}
@@ -366,11 +365,13 @@ impl Assert {
366
365
let output = command. output ( ) ?;
367
366
368
367
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
+ }
374
375
}
375
376
376
377
if self . expect_exit_code . is_some ( ) &&
0 commit comments