@@ -4,7 +4,7 @@ use std::path::PathBuf;
44use std:: vec:: Vec ;
55
66use errors:: * ;
7- use output:: { OutputAssertion , StdErr , StdOut } ;
7+ use output:: { OutputAssertion , OutputKind } ;
88
99/// Assertions for a specific command.
1010#[ derive( Debug ) ]
@@ -13,8 +13,7 @@ pub struct Assert {
1313 current_dir : Option < PathBuf > ,
1414 expect_success : Option < bool > ,
1515 expect_exit_code : Option < i32 > ,
16- expect_stdout : Vec < OutputAssertion < StdOut > > ,
17- expect_stderr : Vec < OutputAssertion < StdErr > > ,
16+ expect_output : Vec < OutputAssertion > ,
1817}
1918
2019impl default:: Default for Assert {
@@ -28,8 +27,7 @@ impl default::Default for Assert {
2827 current_dir : None ,
2928 expect_success : Some ( true ) ,
3029 expect_exit_code : None ,
31- expect_stdout : vec ! [ ] ,
32- expect_stderr : vec ! [ ] ,
30+ expect_output : vec ! [ ] ,
3331 }
3432 }
3533}
@@ -190,11 +188,11 @@ impl Assert {
190188 /// .unwrap();
191189 /// ```
192190 pub fn prints < O : Into < String > > ( mut self , output : O ) -> Self {
193- self . expect_stdout . push ( OutputAssertion {
191+ self . expect_output . push ( OutputAssertion {
194192 expect : output. into ( ) ,
195193 fuzzy : true ,
196194 expected_result : true ,
197- kind : StdOut ,
195+ kind : OutputKind :: StdOut ,
198196 } ) ;
199197 self
200198 }
@@ -211,11 +209,11 @@ impl Assert {
211209 /// .unwrap();
212210 /// ```
213211 pub fn prints_exactly < O : Into < String > > ( mut self , output : O ) -> Self {
214- self . expect_stdout . push ( OutputAssertion {
212+ self . expect_output . push ( OutputAssertion {
215213 expect : output. into ( ) ,
216214 fuzzy : false ,
217215 expected_result : true ,
218- kind : StdOut ,
216+ kind : OutputKind :: StdOut ,
219217 } ) ;
220218 self
221219 }
@@ -234,11 +232,11 @@ impl Assert {
234232 /// .unwrap();
235233 /// ```
236234 pub fn prints_error < O : Into < String > > ( mut self , output : O ) -> Self {
237- self . expect_stderr . push ( OutputAssertion {
235+ self . expect_output . push ( OutputAssertion {
238236 expect : output. into ( ) ,
239237 fuzzy : true ,
240238 expected_result : true ,
241- kind : StdErr ,
239+ kind : OutputKind :: StdErr ,
242240 } ) ;
243241 self
244242 }
@@ -257,11 +255,11 @@ impl Assert {
257255 /// .unwrap();
258256 /// ```
259257 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 {
261259 expect : output. into ( ) ,
262260 fuzzy : false ,
263261 expected_result : true ,
264- kind : StdErr ,
262+ kind : OutputKind :: StdErr ,
265263 } ) ;
266264 self
267265 }
@@ -279,11 +277,11 @@ impl Assert {
279277 /// .unwrap();
280278 /// ```
281279 pub fn doesnt_print < O : Into < String > > ( mut self , output : O ) -> Self {
282- self . expect_stdout . push ( OutputAssertion {
280+ self . expect_output . push ( OutputAssertion {
283281 expect : output. into ( ) ,
284282 fuzzy : true ,
285283 expected_result : false ,
286- kind : StdOut ,
284+ kind : OutputKind :: StdOut ,
287285 } ) ;
288286 self
289287 }
@@ -301,11 +299,11 @@ impl Assert {
301299 /// .unwrap();
302300 /// ```
303301 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 {
305303 expect : output. into ( ) ,
306304 fuzzy : false ,
307305 expected_result : false ,
308- kind : StdOut ,
306+ kind : OutputKind :: StdOut ,
309307 } ) ;
310308 self
311309 }
@@ -325,11 +323,11 @@ impl Assert {
325323 /// .unwrap();
326324 /// ```
327325 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 {
329327 expect : output. into ( ) ,
330328 fuzzy : true ,
331329 expected_result : false ,
332- kind : StdErr ,
330+ kind : OutputKind :: StdErr ,
333331 } ) ;
334332 self
335333 }
@@ -349,11 +347,11 @@ impl Assert {
349347 /// .unwrap();
350348 /// ```
351349 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 {
353351 expect : output. into ( ) ,
354352 fuzzy : false ,
355353 expected_result : false ,
356- kind : StdErr ,
354+ kind : OutputKind :: StdErr ,
357355 } ) ;
358356 self
359357 }
@@ -399,13 +397,9 @@ impl Assert {
399397 ) ) ;
400398 }
401399
402- self . expect_stdout
400+ self . expect_output
403401 . 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 ) )
409403 . collect :: < Result < Vec < ( ) > > > ( ) ?;
410404
411405 Ok ( ( ) )
0 commit comments