1
+ static ERROR_PREFIX : & ' static str = "CLI assertion failed" ;
2
+
1
3
error_chain ! {
2
4
foreign_links {
3
5
Io ( :: std:: io:: Error ) ;
@@ -7,42 +9,60 @@ error_chain! {
7
9
StatusMismatch ( cmd: Vec <String >, expected: bool ) {
8
10
description( "Wrong status" )
9
11
display(
10
- "Command {:?} {got} but expected it to {expected}" ,
12
+ "{}: `(command `{}` expected to {})` (command {})" ,
13
+ ERROR_PREFIX ,
11
14
cmd. join( " " ) ,
12
- got = if * expected { "failed " } else { "succeed " } ,
13
- expected = if * expected { "succeed " } else { "failed " } ,
15
+ expected = if * expected { "succeed " } else { "fail " } ,
16
+ got = if * expected { "failed " } else { "succeeded " } ,
14
17
)
15
18
}
16
19
ExitCodeMismatch ( cmd: Vec <String >, expected: Option <i32 >, got: Option <i32 >) {
17
20
description( "Wrong exit code" )
18
21
display(
19
- "Command {:?} exited with code {:?} but expected it to be {:?}" ,
20
- cmd. join( " " ) , got, expected,
22
+ "{}: `(exit code of `{}` expected to be `{:?}`)` (exit code was: `{:?}`)" ,
23
+ ERROR_PREFIX ,
24
+ cmd. join( " " ) ,
25
+ expected,
26
+ got,
21
27
)
22
28
}
23
- OutputMismatch ( expected: String , got: String ) {
29
+ OutputMismatch ( cmd : Vec < String > , expected: String , got: String ) {
24
30
description( "Output was not as expected" )
25
31
display(
26
- "Expected output to contain\n {}\n but could not find it in\n {}" ,
32
+ "{}: `(output of `{}` expected to contain `{:?}`)` (output was: `{:?}`)" ,
33
+ ERROR_PREFIX ,
34
+ cmd. join( " " ) ,
27
35
expected,
28
36
got,
29
37
)
30
38
}
31
- ExactOutputMismatch ( diff: String ) {
39
+ ExactOutputMismatch ( cmd : Vec < String > , diff: String ) {
32
40
description( "Output was not as expected" )
33
- display( "{}" , diff)
41
+ display(
42
+ "{}: `(output of `{}` was not as expected)`\n {}\n " ,
43
+ ERROR_PREFIX ,
44
+ cmd. join( " " ) ,
45
+ diff. trim( )
46
+ )
34
47
}
35
- ErrorOutputMismatch ( expected: String , got: String ) {
48
+ ErrorOutputMismatch ( cmd : Vec < String > , expected: String , got: String ) {
36
49
description( "Stderr output was not as expected" )
37
50
display(
38
- "Expected stderr output to contain\n {}\n but could not find it in\n {}" ,
51
+ "{}: `(stderr output of `{}` expected to contain `{:?}`)` (stderr was: `{:?}`)" ,
52
+ ERROR_PREFIX ,
53
+ cmd. join( " " ) ,
39
54
expected,
40
55
got,
41
56
)
42
57
}
43
- ExactErrorOutputMismatch ( diff: String ) {
58
+ ExactErrorOutputMismatch ( cmd : Vec < String > , diff: String ) {
44
59
description( "Stderr output was not as expected" )
45
- display( "{}" , diff)
60
+ display(
61
+ "{}: `(stderr output of `{}` was not as expected)`\n {}\n " ,
62
+ ERROR_PREFIX ,
63
+ cmd. join( " " ) ,
64
+ diff. trim( )
65
+ )
46
66
}
47
67
}
48
68
}
0 commit comments