@@ -105,27 +105,20 @@ static EXTERN_FLAGS: LazyLock<Vec<String>> = LazyLock::new(|| {
105
105
// whether to run internal tests or not
106
106
const RUN_INTERNAL_TESTS : bool = cfg ! ( feature = "internal" ) ;
107
107
108
- fn canonicalize ( path : impl AsRef < Path > ) -> PathBuf {
109
- let path = path. as_ref ( ) ;
110
- fs:: create_dir_all ( path) . unwrap ( ) ;
111
- fs:: canonicalize ( path) . unwrap_or_else ( |err| panic ! ( "{} cannot be canonicalized: {err}" , path. display( ) ) )
112
- }
113
-
114
108
fn base_config ( test_dir : & str ) -> ( Config , Args ) {
115
109
let mut args = Args :: test ( ) . unwrap ( ) ;
116
110
args. bless |= var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
117
111
112
+ let target_dir = PathBuf :: from ( var_os ( "CARGO_TARGET_DIR" ) . unwrap_or_else ( || "target" . into ( ) ) ) ;
118
113
let mut config = Config {
119
114
mode : Mode :: Yolo {
120
115
rustfix : ui_test:: RustfixMode :: Everything ,
121
116
} ,
122
- stderr_filters : vec ! [ ( Match :: PathBackslash , b"/" ) ] ,
123
- stdout_filters : vec ! [ ] ,
124
117
filter_files : env:: var ( "TESTNAME" )
125
118
. map ( |filters| filters. split ( ',' ) . map ( str:: to_string) . collect ( ) )
126
119
. unwrap_or_default ( ) ,
127
120
target : None ,
128
- out_dir : canonicalize ( var_os ( "CARGO_TARGET_DIR" ) . unwrap_or_else ( || "target" . into ( ) ) ) . join ( "ui_test" ) ,
121
+ out_dir : target_dir . join ( "ui_test" ) ,
129
122
..Config :: rustc ( Path :: new ( "tests" ) . join ( test_dir) )
130
123
} ;
131
124
config. with_args ( & args, /* bless by default */ false ) ;
@@ -168,19 +161,13 @@ fn run_ui() {
168
161
config
169
162
. program
170
163
. envs
171
- . push ( ( "CLIPPY_CONF_DIR" . into ( ) , Some ( canonicalize ( "tests" ) . into ( ) ) ) ) ;
172
-
173
- let quiet = args. quiet ;
164
+ . push ( ( "CLIPPY_CONF_DIR" . into ( ) , Some ( "tests" . into ( ) ) ) ) ;
174
165
175
166
ui_test:: run_tests_generic (
176
167
vec ! [ config] ,
177
168
ui_test:: default_file_filter,
178
169
ui_test:: default_per_file_config,
179
- if quiet {
180
- status_emitter:: Text :: quiet ( )
181
- } else {
182
- status_emitter:: Text :: verbose ( )
183
- } ,
170
+ status_emitter:: Text :: from ( args. format ) ,
184
171
)
185
172
. unwrap ( ) ;
186
173
}
@@ -194,40 +181,22 @@ fn run_internal_tests() {
194
181
if let OutputConflictHandling :: Error ( err) = & mut config. output_conflict_handling {
195
182
* err = "cargo uitest --features internal -- -- --bless" . into ( ) ;
196
183
}
197
- let quiet = args. quiet ;
198
184
199
185
ui_test:: run_tests_generic (
200
186
vec ! [ config] ,
201
187
ui_test:: default_file_filter,
202
188
ui_test:: default_per_file_config,
203
- if quiet {
204
- status_emitter:: Text :: quiet ( )
205
- } else {
206
- status_emitter:: Text :: verbose ( )
207
- } ,
189
+ status_emitter:: Text :: from ( args. format ) ,
208
190
)
209
191
. unwrap ( ) ;
210
192
}
211
193
212
194
fn run_ui_toml ( ) {
213
195
let ( mut config, args) = base_config ( "ui-toml" ) ;
214
196
215
- config. stderr_filters = vec ! [
216
- (
217
- Match :: Exact (
218
- canonicalize( "tests" )
219
- . parent( )
220
- . unwrap( )
221
- . to_string_lossy( )
222
- . as_bytes( )
223
- . to_vec( ) ,
224
- ) ,
225
- b"$DIR" ,
226
- ) ,
227
- ( Match :: Exact ( b"\\ " . to_vec( ) ) , b"/" ) ,
228
- ] ;
229
-
230
- let quiet = args. quiet ;
197
+ config
198
+ . stderr_filters
199
+ . push ( ( Match :: from ( env:: current_dir ( ) . unwrap ( ) . as_path ( ) ) , b"$DIR" ) ) ;
231
200
232
201
ui_test:: run_tests_generic (
233
202
vec ! [ config] ,
@@ -238,11 +207,7 @@ fn run_ui_toml() {
238
207
. envs
239
208
. push ( ( "CLIPPY_CONF_DIR" . into ( ) , Some ( path. parent ( ) . unwrap ( ) . into ( ) ) ) ) ;
240
209
} ,
241
- if quiet {
242
- status_emitter:: Text :: quiet ( )
243
- } else {
244
- status_emitter:: Text :: verbose ( )
245
- } ,
210
+ status_emitter:: Text :: from ( args. format ) ,
246
211
)
247
212
. unwrap ( ) ;
248
213
}
@@ -270,22 +235,9 @@ fn run_ui_cargo() {
270
235
} ) ;
271
236
config. edition = None ;
272
237
273
- config. stderr_filters = vec ! [
274
- (
275
- Match :: Exact (
276
- canonicalize( "tests" )
277
- . parent( )
278
- . unwrap( )
279
- . to_string_lossy( )
280
- . as_bytes( )
281
- . to_vec( ) ,
282
- ) ,
283
- b"$DIR" ,
284
- ) ,
285
- ( Match :: Exact ( b"\\ " . to_vec( ) ) , b"/" ) ,
286
- ] ;
287
-
288
- let quiet = args. quiet ;
238
+ config
239
+ . stderr_filters
240
+ . push ( ( Match :: from ( env:: current_dir ( ) . unwrap ( ) . as_path ( ) ) , b"$DIR" ) ) ;
289
241
290
242
let ignored_32bit = |path : & Path | {
291
243
// FIXME: for some reason the modules are linted in a different order for this test
@@ -297,20 +249,8 @@ fn run_ui_cargo() {
297
249
|path, config| {
298
250
path. ends_with ( "Cargo.toml" ) && ui_test:: default_any_file_filter ( path, config) && !ignored_32bit ( path)
299
251
} ,
300
- |config, path, _file_contents| {
301
- config. out_dir = canonicalize (
302
- std:: env:: current_dir ( )
303
- . unwrap ( )
304
- . join ( "target" )
305
- . join ( "ui_test_cargo/" )
306
- . join ( path. parent ( ) . unwrap ( ) ) ,
307
- ) ;
308
- } ,
309
- if quiet {
310
- status_emitter:: Text :: quiet ( )
311
- } else {
312
- status_emitter:: Text :: verbose ( )
313
- } ,
252
+ |_config, _path, _file_contents| { } ,
253
+ status_emitter:: Text :: from ( args. format ) ,
314
254
)
315
255
. unwrap ( ) ;
316
256
}
0 commit comments