@@ -95,12 +95,23 @@ macro_rules! test_prepare_error {
95
95
rustwide:: cmd:: SandboxBuilder :: new( ) . enable_networking( false ) ,
96
96
|_| Ok ( ( ) ) ,
97
97
) ;
98
- if let Some ( rustwide:: PrepareError :: $expected) =
99
- res. err( ) . and_then( |err| err. downcast( ) . ok( ) )
100
- {
101
- // Everything is OK!
102
- } else {
103
- panic!( "didn't get the error {}" , stringify!( $expected) ) ;
98
+ match res. err( ) . and_then( |err| err. downcast( ) . ok( ) ) {
99
+ Some ( rustwide:: PrepareError :: $expected) => {
100
+ // Everything is OK!
101
+ }
102
+ Some ( other) => {
103
+ panic!(
104
+ "expected PrepareError::{} error, got {:?} instead" ,
105
+ stringify!( $expected) ,
106
+ other
107
+ ) ;
108
+ }
109
+ None => {
110
+ panic!(
111
+ "expected PrepareError::{} error, but did get None instead" ,
112
+ stringify!( $expected)
113
+ ) ;
114
+ }
104
115
}
105
116
Ok ( ( ) )
106
117
} ) ;
@@ -117,12 +128,23 @@ macro_rules! test_prepare_error_stderr {
117
128
rustwide:: cmd:: SandboxBuilder :: new( ) . enable_networking( false ) ,
118
129
|_| Ok ( ( ) ) ,
119
130
) ;
120
- if let Some ( rustwide:: PrepareError :: $expected( output) ) =
121
- res. err( ) . and_then( |err| err. downcast( ) . ok( ) )
122
- {
123
- assert!( output. contains( $expected_output) , "output: {:?}" , output) ;
124
- } else {
125
- panic!( "didn't get the error {}" , stringify!( $expected) ) ;
131
+ match res. err( ) . and_then( |err| err. downcast( ) . ok( ) ) {
132
+ Some ( rustwide:: PrepareError :: $expected( output) ) => {
133
+ assert!( output. contains( $expected_output) , "output: {:?}" , output) ;
134
+ }
135
+ Some ( other) => {
136
+ panic!(
137
+ "expected PrepareError::{} error, got {:?} instead" ,
138
+ stringify!( $expected) ,
139
+ other
140
+ ) ;
141
+ }
142
+ None => {
143
+ panic!(
144
+ "expected PrepareError::{} error, but did get None instead" ,
145
+ stringify!( $expected)
146
+ ) ;
147
+ }
126
148
}
127
149
Ok ( ( ) )
128
150
} ) ;
0 commit comments