1
1
use super :: { flags:: Flags , ChangeIdWrapper , Config } ;
2
2
use crate :: core:: config:: { LldMode , TomlConfig } ;
3
+ use crate :: core:: build_steps:: check:: get_clippy_rules_in_order;
3
4
4
5
use clap:: CommandFactory ;
5
6
use serde:: Deserialize ;
@@ -11,12 +12,13 @@ use std::{
11
12
} ;
12
13
13
14
fn parse ( config : & str ) -> Config {
14
- let config = format ! ( "{config} \r \n build.rustc = \" /does-not-exists\" " ) ;
15
15
Config :: parse_inner (
16
16
& [
17
- "check" . to_owned ( ) ,
18
- "--config=/does/not/exist" . to_owned ( ) ,
19
- "--skip-stage0-validation" . to_owned ( ) ,
17
+ "check" . to_string ( ) ,
18
+ "--set=build.rustc=/does/not/exist" . to_string ( ) ,
19
+ "--set=build.cargo=/does/not/exist" . to_string ( ) ,
20
+ "--config=/does/not/exist" . to_string ( ) ,
21
+ "--skip-stage0-validation" . to_string ( ) ,
20
22
] ,
21
23
|& _| toml:: from_str ( & config) . unwrap ( ) ,
22
24
)
@@ -169,7 +171,10 @@ fn override_toml_duplicate() {
169
171
Config :: parse_inner (
170
172
& [
171
173
"check" . to_owned ( ) ,
174
+ "--set=build.rustc=/does/not/exist" . to_string ( ) ,
175
+ "--set=build.cargo=/does/not/exist" . to_string ( ) ,
172
176
"--config=/does/not/exist" . to_owned ( ) ,
177
+ "--skip-stage0-validation" . to_owned ( ) ,
173
178
"--set=change-id=1" . to_owned ( ) ,
174
179
"--set=change-id=2" . to_owned ( ) ,
175
180
] ,
@@ -192,7 +197,15 @@ fn profile_user_dist() {
192
197
. and_then ( |table : toml:: Value | TomlConfig :: deserialize ( table) )
193
198
. unwrap ( )
194
199
}
195
- Config :: parse_inner ( & [ "check" . to_owned ( ) ] , get_toml) ;
200
+ Config :: parse_inner (
201
+ & [
202
+ "check" . to_owned ( ) ,
203
+ "--set=build.rustc=/does/not/exist" . to_string ( ) ,
204
+ "--set=build.cargo=/does/not/exist" . to_string ( ) ,
205
+ "--skip-stage0-validation" . to_string ( ) ,
206
+ ] ,
207
+ get_toml,
208
+ ) ;
196
209
}
197
210
198
211
#[ test]
@@ -254,3 +267,34 @@ fn parse_change_id_with_unknown_field() {
254
267
let change_id_wrapper: ChangeIdWrapper = toml:: from_str ( config) . unwrap ( ) ;
255
268
assert_eq ! ( change_id_wrapper. inner, Some ( 3461 ) ) ;
256
269
}
270
+
271
+ #[ test]
272
+ fn order_of_clippy_rules ( ) {
273
+ let args = vec ! [
274
+ "clippy" . to_string( ) ,
275
+ "--fix" . to_string( ) ,
276
+ "--allow-dirty" . to_string( ) ,
277
+ "--allow-staged" . to_string( ) ,
278
+ "-Aclippy:all" . to_string( ) ,
279
+ "-Wclippy::style" . to_string( ) ,
280
+ "-Aclippy::foo1" . to_string( ) ,
281
+ "-Aclippy::foo2" . to_string( ) ,
282
+ ] ;
283
+ let config = Config :: parse ( & args) ;
284
+
285
+ let actual = match & config. cmd {
286
+ crate :: Subcommand :: Clippy { allow, deny, warn, forbid, .. } => {
287
+ get_clippy_rules_in_order ( & args, & allow, & deny, & warn, & forbid)
288
+ }
289
+ _ => panic ! ( "invalid subcommand" ) ,
290
+ } ;
291
+
292
+ let expected = vec ! [
293
+ "-Aclippy:all" . to_string( ) ,
294
+ "-Wclippy::style" . to_string( ) ,
295
+ "-Aclippy::foo1" . to_string( ) ,
296
+ "-Aclippy::foo2" . to_string( ) ,
297
+ ] ;
298
+
299
+ assert_eq ! ( expected, actual) ;
300
+ }
0 commit comments