4
4
#![ warn( rust_2018_idioms, unused_lifetimes) ]
5
5
#![ allow( unused_extern_crates) ]
6
6
7
- use ui_test:: { status_emitter, Args , CommandBuilder , Config , Match , Mode , OutputConflictHandling } ;
7
+ use ui_test:: spanned:: Spanned ;
8
+ use ui_test:: { status_emitter, Args , CommandBuilder , Config , Match , Mode } ;
8
9
9
10
use std:: collections:: BTreeMap ;
10
11
use std:: env:: { self , set_var, var_os} ;
@@ -112,20 +113,21 @@ fn base_config(test_dir: &str) -> (Config, Args) {
112
113
113
114
let target_dir = PathBuf :: from ( var_os ( "CARGO_TARGET_DIR" ) . unwrap_or_else ( || "target" . into ( ) ) ) ;
114
115
let mut config = Config {
115
- mode : Mode :: Yolo {
116
- rustfix : ui_test:: RustfixMode :: Everything ,
117
- } ,
118
116
filter_files : env:: var ( "TESTNAME" )
119
117
. map ( |filters| filters. split ( ',' ) . map ( str:: to_string) . collect ( ) )
120
118
. unwrap_or_default ( ) ,
121
119
target : None ,
120
+ bless_command : Some ( "cargo uibless" . into ( ) ) ,
122
121
out_dir : target_dir. join ( "ui_test" ) ,
123
122
..Config :: rustc ( Path :: new ( "tests" ) . join ( test_dir) )
124
123
} ;
125
- config. with_args ( & args, /* bless by default */ false ) ;
126
- if let OutputConflictHandling :: Error ( err) = & mut config. output_conflict_handling {
127
- * err = "cargo uibless" . into ( ) ;
128
- }
124
+ config. comment_defaults . base ( ) . mode = Some ( Spanned :: dummy ( Mode :: Yolo {
125
+ rustfix : ui_test:: RustfixMode :: Everything ,
126
+ } ) )
127
+ . into ( ) ;
128
+ config. comment_defaults . base ( ) . diagnostic_code_prefix = Some ( Spanned :: dummy ( "clippy::" . into ( ) ) ) . into ( ) ;
129
+ config. filter ( & format ! ( "tests/{test_dir}" ) , "$$DIR" ) ;
130
+ config. with_args ( & args) ;
129
131
let current_exe_path = env:: current_exe ( ) . unwrap ( ) ;
130
132
let deps_path = current_exe_path. parent ( ) . unwrap ( ) ;
131
133
let profile_path = deps_path. parent ( ) . unwrap ( ) ;
@@ -179,9 +181,7 @@ fn run_internal_tests() {
179
181
return ;
180
182
}
181
183
let ( mut config, args) = base_config ( "ui-internal" ) ;
182
- if let OutputConflictHandling :: Error ( err) = & mut config. output_conflict_handling {
183
- * err = "cargo uitest --features internal -- -- --bless" . into ( ) ;
184
- }
184
+ config. bless_command = Some ( "cargo uitest --features internal -- -- --bless" . into ( ) ) ;
185
185
186
186
ui_test:: run_tests_generic (
187
187
vec ! [ config] ,
@@ -196,8 +196,10 @@ fn run_ui_toml() {
196
196
let ( mut config, args) = base_config ( "ui-toml" ) ;
197
197
198
198
config
199
- . stderr_filters
200
- . push ( ( Match :: from ( env:: current_dir ( ) . unwrap ( ) . as_path ( ) ) , b"$DIR" ) ) ;
199
+ . comment_defaults
200
+ . base ( )
201
+ . normalize_stderr
202
+ . push ( ( Match :: from ( env:: current_dir ( ) . unwrap ( ) . as_path ( ) ) , b"$DIR" . into ( ) ) ) ;
201
203
202
204
ui_test:: run_tests_generic (
203
205
vec ! [ config] ,
@@ -213,6 +215,8 @@ fn run_ui_toml() {
213
215
. unwrap ( ) ;
214
216
}
215
217
218
+ // Allow `Default::default` as `OptWithSpan` is not nameable
219
+ #[ allow( clippy:: default_trait_access) ]
216
220
fn run_ui_cargo ( ) {
217
221
if IS_RUSTC_TEST_SUITE {
218
222
return ;
@@ -234,11 +238,13 @@ fn run_ui_cargo() {
234
238
} else {
235
239
"cargo-clippy"
236
240
} ) ;
237
- config. edition = None ;
241
+ config. comment_defaults . base ( ) . edition = Default :: default ( ) ;
238
242
239
243
config
240
- . stderr_filters
241
- . push ( ( Match :: from ( env:: current_dir ( ) . unwrap ( ) . as_path ( ) ) , b"$DIR" ) ) ;
244
+ . comment_defaults
245
+ . base ( )
246
+ . normalize_stderr
247
+ . push ( ( Match :: from ( env:: current_dir ( ) . unwrap ( ) . as_path ( ) ) , b"$DIR" . into ( ) ) ) ;
242
248
243
249
let ignored_32bit = |path : & Path | {
244
250
// FIXME: for some reason the modules are linted in a different order for this test
@@ -248,7 +254,8 @@ fn run_ui_cargo() {
248
254
ui_test:: run_tests_generic (
249
255
vec ! [ config] ,
250
256
|path, config| {
251
- path. ends_with ( "Cargo.toml" ) && ui_test:: default_any_file_filter ( path, config) && !ignored_32bit ( path)
257
+ path. ends_with ( "Cargo.toml" )
258
+ . then ( || ui_test:: default_any_file_filter ( path, config) && !ignored_32bit ( path) )
252
259
} ,
253
260
|_config, _path, _file_contents| { } ,
254
261
status_emitter:: Text :: from ( args. format ) ,
0 commit comments