@@ -35,7 +35,7 @@ impl OutputAssertion {
3535 if result != self . expected_result {
3636 if self . expected_result {
3737 let nice_diff = diff:: render ( & differences) ?;
38- bail ! ( ErrorKind :: OutputDoesntMatch ( nice_diff) ) ;
38+ bail ! ( ErrorKind :: OutputDoesntMatch ( self . expect . clone ( ) , got . to_owned ( ) , nice_diff) ) ;
3939 } else {
4040 bail ! ( ErrorKind :: OutputMatches ( got. to_owned( ) ) ) ;
4141 }
@@ -52,7 +52,9 @@ impl OutputAssertion {
5252 } else {
5353 self . matches_exact ( & observed)
5454 } ;
55- result. map_err ( |e| self . kind . map_err ( e, cmd) )
55+ result. map_err ( |e| super :: errors:: ErrorKind :: OutputMismatch ( cmd. to_vec ( ) , e, self . kind ) ) ?;
56+
57+ Ok ( ( ) )
5658 }
5759}
5860
@@ -69,13 +71,6 @@ impl OutputKind {
6971 OutputKind :: StdErr => & o. stderr ,
7072 }
7173 }
72-
73- pub fn map_err ( self , e : Error , cmd : & [ String ] ) -> super :: errors:: Error {
74- match self {
75- OutputKind :: StdOut => super :: errors:: ErrorKind :: StdoutMismatch ( cmd. to_vec ( ) , e) . into ( ) ,
76- OutputKind :: StdErr => super :: errors:: ErrorKind :: StderrMismatch ( cmd. to_vec ( ) , e) . into ( ) ,
77- }
78- }
7974}
8075
8176mod errors {
@@ -86,19 +81,19 @@ mod errors {
8681 errors {
8782 OutputDoesntContain ( expected: String , got: String ) {
8883 description( "Output was not as expected" )
89- display( "expected to contain {:?}, got {:?} " , expected, got)
84+ display( "expected to contain {:?}\n output=```{}``` " , expected, got)
9085 }
9186 OutputContains ( expected: String , got: String ) {
9287 description( "Output was not as expected" )
93- display( "expected to not contain {:?}, got {:?} " , expected, got)
88+ display( "expected to not contain {:?}\n output=```{}``` " , expected, got)
9489 }
95- OutputDoesntMatch ( diff: String ) {
90+ OutputDoesntMatch ( expected : String , got : String , diff: String ) {
9691 description( "Output was not as expected" )
97- display( "{}" , diff)
92+ display( "diff: \n {}" , diff)
9893 }
9994 OutputMatches ( got: String ) {
10095 description( "Output was not as expected" )
101- display( "{} " , got)
96+ display( "expected to not match \n output=```{}``` " , got)
10297 }
10398 }
10499 }
0 commit comments