@@ -4,7 +4,7 @@ use std::path::PathBuf;
4
4
use std:: vec:: Vec ;
5
5
6
6
use errors:: * ;
7
- use output:: { OutputAssertion , StdErr , StdOut } ;
7
+ use output:: { OutputAssertion , OutputKind } ;
8
8
9
9
/// Assertions for a specific command.
10
10
#[ derive( Debug ) ]
@@ -13,8 +13,7 @@ pub struct Assert {
13
13
current_dir : Option < PathBuf > ,
14
14
expect_success : Option < bool > ,
15
15
expect_exit_code : Option < i32 > ,
16
- expect_stdout : Vec < OutputAssertion < StdOut > > ,
17
- expect_stderr : Vec < OutputAssertion < StdErr > > ,
16
+ expect_output : Vec < OutputAssertion > ,
18
17
}
19
18
20
19
impl default:: Default for Assert {
@@ -28,8 +27,7 @@ impl default::Default for Assert {
28
27
current_dir : None ,
29
28
expect_success : Some ( true ) ,
30
29
expect_exit_code : None ,
31
- expect_stdout : vec ! [ ] ,
32
- expect_stderr : vec ! [ ] ,
30
+ expect_output : vec ! [ ] ,
33
31
}
34
32
}
35
33
}
@@ -190,11 +188,11 @@ impl Assert {
190
188
/// .unwrap();
191
189
/// ```
192
190
pub fn prints < O : Into < String > > ( mut self , output : O ) -> Self {
193
- self . expect_stdout . push ( OutputAssertion {
191
+ self . expect_output . push ( OutputAssertion {
194
192
expect : output. into ( ) ,
195
193
fuzzy : true ,
196
194
expected_result : true ,
197
- kind : StdOut ,
195
+ kind : OutputKind :: StdOut ,
198
196
} ) ;
199
197
self
200
198
}
@@ -211,11 +209,11 @@ impl Assert {
211
209
/// .unwrap();
212
210
/// ```
213
211
pub fn prints_exactly < O : Into < String > > ( mut self , output : O ) -> Self {
214
- self . expect_stdout . push ( OutputAssertion {
212
+ self . expect_output . push ( OutputAssertion {
215
213
expect : output. into ( ) ,
216
214
fuzzy : false ,
217
215
expected_result : true ,
218
- kind : StdOut ,
216
+ kind : OutputKind :: StdOut ,
219
217
} ) ;
220
218
self
221
219
}
@@ -234,11 +232,11 @@ impl Assert {
234
232
/// .unwrap();
235
233
/// ```
236
234
pub fn prints_error < O : Into < String > > ( mut self , output : O ) -> Self {
237
- self . expect_stderr . push ( OutputAssertion {
235
+ self . expect_output . push ( OutputAssertion {
238
236
expect : output. into ( ) ,
239
237
fuzzy : true ,
240
238
expected_result : true ,
241
- kind : StdErr ,
239
+ kind : OutputKind :: StdErr ,
242
240
} ) ;
243
241
self
244
242
}
@@ -257,11 +255,11 @@ impl Assert {
257
255
/// .unwrap();
258
256
/// ```
259
257
pub fn prints_error_exactly < O : Into < String > > ( mut self , output : O ) -> Self {
260
- self . expect_stderr . push ( OutputAssertion {
258
+ self . expect_output . push ( OutputAssertion {
261
259
expect : output. into ( ) ,
262
260
fuzzy : false ,
263
261
expected_result : true ,
264
- kind : StdErr ,
262
+ kind : OutputKind :: StdErr ,
265
263
} ) ;
266
264
self
267
265
}
@@ -279,11 +277,11 @@ impl Assert {
279
277
/// .unwrap();
280
278
/// ```
281
279
pub fn doesnt_print < O : Into < String > > ( mut self , output : O ) -> Self {
282
- self . expect_stdout . push ( OutputAssertion {
280
+ self . expect_output . push ( OutputAssertion {
283
281
expect : output. into ( ) ,
284
282
fuzzy : true ,
285
283
expected_result : false ,
286
- kind : StdOut ,
284
+ kind : OutputKind :: StdOut ,
287
285
} ) ;
288
286
self
289
287
}
@@ -301,11 +299,11 @@ impl Assert {
301
299
/// .unwrap();
302
300
/// ```
303
301
pub fn doesnt_print_exactly < O : Into < String > > ( mut self , output : O ) -> Self {
304
- self . expect_stdout . push ( OutputAssertion {
302
+ self . expect_output . push ( OutputAssertion {
305
303
expect : output. into ( ) ,
306
304
fuzzy : false ,
307
305
expected_result : false ,
308
- kind : StdOut ,
306
+ kind : OutputKind :: StdOut ,
309
307
} ) ;
310
308
self
311
309
}
@@ -325,11 +323,11 @@ impl Assert {
325
323
/// .unwrap();
326
324
/// ```
327
325
pub fn doesnt_print_error < O : Into < String > > ( mut self , output : O ) -> Self {
328
- self . expect_stderr . push ( OutputAssertion {
326
+ self . expect_output . push ( OutputAssertion {
329
327
expect : output. into ( ) ,
330
328
fuzzy : true ,
331
329
expected_result : false ,
332
- kind : StdErr ,
330
+ kind : OutputKind :: StdErr ,
333
331
} ) ;
334
332
self
335
333
}
@@ -349,11 +347,11 @@ impl Assert {
349
347
/// .unwrap();
350
348
/// ```
351
349
pub fn doesnt_print_error_exactly < O : Into < String > > ( mut self , output : O ) -> Self {
352
- self . expect_stderr . push ( OutputAssertion {
350
+ self . expect_output . push ( OutputAssertion {
353
351
expect : output. into ( ) ,
354
352
fuzzy : false ,
355
353
expected_result : false ,
356
- kind : StdErr ,
354
+ kind : OutputKind :: StdErr ,
357
355
} ) ;
358
356
self
359
357
}
@@ -399,13 +397,9 @@ impl Assert {
399
397
) ) ;
400
398
}
401
399
402
- self . expect_stdout
400
+ self . expect_output
403
401
. iter ( )
404
- . map ( |a| a. execute ( & output) . map_err ( |e| ErrorKind :: StdoutMismatch ( self . cmd . clone ( ) , e) . into ( ) ) )
405
- . collect :: < Result < Vec < ( ) > > > ( ) ?;
406
- self . expect_stderr
407
- . iter ( )
408
- . map ( |a| a. execute ( & output) . map_err ( |e| ErrorKind :: StderrMismatch ( self . cmd . clone ( ) , e) . into ( ) ) )
402
+ . map ( |a| a. execute ( & output, & self . cmd ) )
409
403
. collect :: < Result < Vec < ( ) > > > ( ) ?;
410
404
411
405
Ok ( ( ) )
0 commit comments