File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -181,3 +181,40 @@ where
181
181
Err ( exit_status. code ( ) . unwrap_or ( -1 ) )
182
182
}
183
183
}
184
+
185
+ #[ cfg( test) ]
186
+ mod tests {
187
+ use super :: * ;
188
+
189
+ #[ test]
190
+ #[ should_panic]
191
+ fn fix_without_unstable ( ) {
192
+ let args = "cargo clippy --fix" . split_whitespace ( ) . map ( ToString :: to_string) ;
193
+ let _ = ClippyCmd :: new ( args) ;
194
+ }
195
+
196
+ #[ test]
197
+ fn fix_unstable ( ) {
198
+ let args = "cargo clippy --fix -Zunstable-options" . split_whitespace ( ) . map ( ToString :: to_string) ;
199
+ let cmd = ClippyCmd :: new ( args) ;
200
+ assert_eq ! ( "fix" , cmd. cmd) ;
201
+ assert_eq ! ( "RUSTC_WORKSPACE_WRAPPER" , cmd. path_env( ) ) ;
202
+ assert ! ( cmd. args. iter( ) . find( |arg| arg. ends_with( "unstable-options" ) ) . is_some( ) ) ;
203
+ }
204
+
205
+ #[ test]
206
+ fn check ( ) {
207
+ let args = "cargo clippy" . split_whitespace ( ) . map ( ToString :: to_string) ;
208
+ let cmd = ClippyCmd :: new ( args) ;
209
+ assert_eq ! ( "check" , cmd. cmd) ;
210
+ assert_eq ! ( "RUSTC_WRAPPER" , cmd. path_env( ) ) ;
211
+ }
212
+
213
+ #[ test]
214
+ fn check_unstable ( ) {
215
+ let args = "cargo clippy -Zunstable-options" . split_whitespace ( ) . map ( ToString :: to_string) ;
216
+ let cmd = ClippyCmd :: new ( args) ;
217
+ assert_eq ! ( "check" , cmd. cmd) ;
218
+ assert_eq ! ( "RUSTC_WORKSPACE_WRAPPER" , cmd. path_env( ) ) ;
219
+ }
220
+ }
You can’t perform that action at this time.
0 commit comments