@@ -35,7 +35,7 @@ impl OutputAssertion {
35
35
if result != self . expected_result {
36
36
if self . expected_result {
37
37
let nice_diff = diff:: render ( & differences) ?;
38
- bail ! ( ErrorKind :: OutputDoesntMatch ( nice_diff) ) ;
38
+ bail ! ( ErrorKind :: OutputDoesntMatch ( self . expect . clone ( ) , got . to_owned ( ) , nice_diff) ) ;
39
39
} else {
40
40
bail ! ( ErrorKind :: OutputMatches ( got. to_owned( ) ) ) ;
41
41
}
@@ -52,7 +52,9 @@ impl OutputAssertion {
52
52
} else {
53
53
self . matches_exact ( & observed)
54
54
} ;
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 ( ( ) )
56
58
}
57
59
}
58
60
@@ -69,13 +71,6 @@ impl OutputKind {
69
71
OutputKind :: StdErr => & o. stderr ,
70
72
}
71
73
}
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
- }
79
74
}
80
75
81
76
mod errors {
@@ -86,19 +81,19 @@ mod errors {
86
81
errors {
87
82
OutputDoesntContain ( expected: String , got: String ) {
88
83
description( "Output was not as expected" )
89
- display( "expected to contain {:?}, got {:?} " , expected, got)
84
+ display( "expected to contain {:?}\n output=```{}``` " , expected, got)
90
85
}
91
86
OutputContains ( expected: String , got: String ) {
92
87
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)
94
89
}
95
- OutputDoesntMatch ( diff: String ) {
90
+ OutputDoesntMatch ( expected : String , got : String , diff: String ) {
96
91
description( "Output was not as expected" )
97
- display( "{}" , diff)
92
+ display( "diff: \n {}" , diff)
98
93
}
99
94
OutputMatches ( got: String ) {
100
95
description( "Output was not as expected" )
101
- display( "{} " , got)
96
+ display( "expected to not match \n output=```{}``` " , got)
102
97
}
103
98
}
104
99
}
0 commit comments