1
1
use super :: { flags:: Flags , Config } ;
2
- use crate :: core:: config:: { LldMode , TomlConfig } ;
2
+ use crate :: core:: {
3
+ build_steps:: check:: get_clippy_rules_in_order,
4
+ config:: { LldMode , TomlConfig } ,
5
+ } ;
3
6
4
7
use clap:: CommandFactory ;
5
8
use serde:: Deserialize ;
@@ -11,12 +14,13 @@ use std::{
11
14
} ;
12
15
13
16
fn parse ( config : & str ) -> Config {
14
- let config = format ! ( "{config} \r \n build.rustc = \" /does-not-exists\" " ) ;
15
17
Config :: parse_inner (
16
18
& [
17
- "check" . to_owned ( ) ,
18
- "--config=/does/not/exist" . to_owned ( ) ,
19
- "--skip-stage0-validation" . to_owned ( ) ,
19
+ "check" . to_string ( ) ,
20
+ "--set=build.rustc=/does/not/exist" . to_string ( ) ,
21
+ "--set=build.cargo=/does/not/exist" . to_string ( ) ,
22
+ "--config=/does/not/exist" . to_string ( ) ,
23
+ "--skip-stage0-validation" . to_string ( ) ,
20
24
] ,
21
25
|& _| toml:: from_str ( & config) . unwrap ( ) ,
22
26
)
@@ -169,7 +173,10 @@ fn override_toml_duplicate() {
169
173
Config :: parse_inner (
170
174
& [
171
175
"check" . to_owned ( ) ,
176
+ "--set=build.rustc=/does/not/exist" . to_string ( ) ,
177
+ "--set=build.cargo=/does/not/exist" . to_string ( ) ,
172
178
"--config=/does/not/exist" . to_owned ( ) ,
179
+ "--skip-stage0-validation" . to_owned ( ) ,
173
180
"--set=change-id=1" . to_owned ( ) ,
174
181
"--set=change-id=2" . to_owned ( ) ,
175
182
] ,
@@ -192,7 +199,15 @@ fn profile_user_dist() {
192
199
. and_then ( |table : toml:: Value | TomlConfig :: deserialize ( table) )
193
200
. unwrap ( )
194
201
}
195
- Config :: parse_inner ( & [ "check" . to_owned ( ) ] , get_toml) ;
202
+ Config :: parse_inner (
203
+ & [
204
+ "check" . to_owned ( ) ,
205
+ "--set=build.rustc=/does/not/exist" . to_string ( ) ,
206
+ "--set=build.cargo=/does/not/exist" . to_string ( ) ,
207
+ "--skip-stage0-validation" . to_string ( ) ,
208
+ ] ,
209
+ get_toml,
210
+ ) ;
196
211
}
197
212
198
213
#[ test]
@@ -237,3 +252,34 @@ fn rust_lld() {
237
252
assert ! ( matches!( parse( "rust.use-lld = true" ) . lld_mode, LldMode :: External ) ) ;
238
253
assert ! ( matches!( parse( "rust.use-lld = false" ) . lld_mode, LldMode :: Unused ) ) ;
239
254
}
255
+
256
+ #[ test]
257
+ fn order_of_clippy_rules ( ) {
258
+ let args = vec ! [
259
+ "clippy" . to_string( ) ,
260
+ "--fix" . to_string( ) ,
261
+ "--allow-dirty" . to_string( ) ,
262
+ "--allow-staged" . to_string( ) ,
263
+ "-Aclippy:all" . to_string( ) ,
264
+ "-Wclippy::style" . to_string( ) ,
265
+ "-Aclippy::foo1" . to_string( ) ,
266
+ "-Aclippy::foo2" . to_string( ) ,
267
+ ] ;
268
+ let config = Config :: parse ( & args) ;
269
+
270
+ let actual = match & config. cmd {
271
+ crate :: Subcommand :: Clippy { allow, deny, warn, forbid, .. } => {
272
+ get_clippy_rules_in_order ( & args, & allow, & deny, & warn, & forbid)
273
+ }
274
+ _ => panic ! ( "invalid subcommand" ) ,
275
+ } ;
276
+
277
+ let expected = vec ! [
278
+ "-Aclippy:all" . to_string( ) ,
279
+ "-Wclippy::style" . to_string( ) ,
280
+ "-Aclippy::foo1" . to_string( ) ,
281
+ "-Aclippy::foo2" . to_string( ) ,
282
+ ] ;
283
+
284
+ assert_eq ! ( expected, actual) ;
285
+ }
0 commit comments