@@ -105,27 +105,20 @@ static EXTERN_FLAGS: LazyLock<Vec<String>> = LazyLock::new(|| {
105105// whether to run internal tests or not
106106const RUN_INTERNAL_TESTS : bool = cfg ! ( feature = "internal" ) ;
107107
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-
114108fn base_config ( test_dir : & str ) -> ( Config , Args ) {
115109 let mut args = Args :: test ( ) . unwrap ( ) ;
116110 args. bless |= var_os ( "RUSTC_BLESS" ) . is_some_and ( |v| v != "0" ) ;
117111
112+ let target_dir = PathBuf :: from ( var_os ( "CARGO_TARGET_DIR" ) . unwrap_or_else ( || "target" . into ( ) ) ) ;
118113 let mut config = Config {
119114 mode : Mode :: Yolo {
120115 rustfix : ui_test:: RustfixMode :: Everything ,
121116 } ,
122- stderr_filters : vec ! [ ( Match :: PathBackslash , b"/" ) ] ,
123- stdout_filters : vec ! [ ] ,
124117 filter_files : env:: var ( "TESTNAME" )
125118 . map ( |filters| filters. split ( ',' ) . map ( str:: to_string) . collect ( ) )
126119 . unwrap_or_default ( ) ,
127120 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" ) ,
129122 ..Config :: rustc ( Path :: new ( "tests" ) . join ( test_dir) )
130123 } ;
131124 config. with_args ( & args, /* bless by default */ false ) ;
@@ -168,19 +161,13 @@ fn run_ui() {
168161 config
169162 . program
170163 . 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 ( ) ) ) ) ;
174165
175166 ui_test:: run_tests_generic (
176167 vec ! [ config] ,
177168 ui_test:: default_file_filter,
178169 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 ) ,
184171 )
185172 . unwrap ( ) ;
186173}
@@ -194,40 +181,22 @@ fn run_internal_tests() {
194181 if let OutputConflictHandling :: Error ( err) = & mut config. output_conflict_handling {
195182 * err = "cargo uitest --features internal -- -- --bless" . into ( ) ;
196183 }
197- let quiet = args. quiet ;
198184
199185 ui_test:: run_tests_generic (
200186 vec ! [ config] ,
201187 ui_test:: default_file_filter,
202188 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 ) ,
208190 )
209191 . unwrap ( ) ;
210192}
211193
212194fn run_ui_toml ( ) {
213195 let ( mut config, args) = base_config ( "ui-toml" ) ;
214196
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" ) ) ;
231200
232201 ui_test:: run_tests_generic (
233202 vec ! [ config] ,
@@ -238,11 +207,7 @@ fn run_ui_toml() {
238207 . envs
239208 . push ( ( "CLIPPY_CONF_DIR" . into ( ) , Some ( path. parent ( ) . unwrap ( ) . into ( ) ) ) ) ;
240209 } ,
241- if quiet {
242- status_emitter:: Text :: quiet ( )
243- } else {
244- status_emitter:: Text :: verbose ( )
245- } ,
210+ status_emitter:: Text :: from ( args. format ) ,
246211 )
247212 . unwrap ( ) ;
248213}
@@ -270,22 +235,9 @@ fn run_ui_cargo() {
270235 } ) ;
271236 config. edition = None ;
272237
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" ) ) ;
289241
290242 let ignored_32bit = |path : & Path | {
291243 // FIXME: for some reason the modules are linted in a different order for this test
@@ -297,20 +249,8 @@ fn run_ui_cargo() {
297249 |path, config| {
298250 path. ends_with ( "Cargo.toml" ) && ui_test:: default_any_file_filter ( path, config) && !ignored_32bit ( path)
299251 } ,
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 ) ,
314254 )
315255 . unwrap ( ) ;
316256}
0 commit comments