@@ -5,21 +5,39 @@ use super::read_config;
55
66use crate :: { FileName , Input , Session } ;
77
8- #[ test]
9- fn nested_out_of_line_mods_loaded ( ) {
10- // See also https://github.com/rust-lang/rustfmt/issues/4874
11- let filename = "tests/mod-resolver/issue-4874/main.rs" ;
12- let input_file = PathBuf :: from ( filename) ;
8+ fn verify_mod_resolution ( input_file_name : & str , exp_misformatted_files : & [ & str ] ) {
9+ let input_file = PathBuf :: from ( input_file_name) ;
1310 let config = read_config ( & input_file) ;
1411 let mut session = Session :: < io:: Stdout > :: new ( config, None ) ;
1512 let report = session
16- . format ( Input :: File ( filename . into ( ) ) )
13+ . format ( Input :: File ( input_file_name . into ( ) ) )
1714 . expect ( "Should not have had any execution errors" ) ;
1815 let errors_by_file = & report. internal . borrow ( ) . 0 ;
19- assert ! ( errors_by_file. contains_key( & FileName :: Real ( PathBuf :: from(
20- "tests/mod-resolver/issue-4874/bar/baz.rs" ,
21- ) ) ) ) ;
22- assert ! ( errors_by_file. contains_key( & FileName :: Real ( PathBuf :: from(
23- "tests/mod-resolver/issue-4874/foo/qux.rs" ,
24- ) ) ) ) ;
16+ for exp_file in exp_misformatted_files {
17+ assert ! ( errors_by_file. contains_key( & FileName :: Real ( PathBuf :: from( exp_file) ) ) ) ;
18+ }
19+ }
20+
21+ #[ test]
22+ fn nested_out_of_line_mods_loaded ( ) {
23+ // See also https://github.com/rust-lang/rustfmt/issues/4874
24+ verify_mod_resolution (
25+ "tests/mod-resolver/issue-4874/main.rs" ,
26+ & [
27+ "tests/mod-resolver/issue-4874/bar/baz.rs" ,
28+ "tests/mod-resolver/issue-4874/foo/qux.rs" ,
29+ ] ,
30+ ) ;
31+ }
32+
33+ #[ test]
34+ fn out_of_line_nested_inline_within_out_of_line ( ) {
35+ // See also https://github.com/rust-lang/rustfmt/issues/5063
36+ verify_mod_resolution (
37+ "tests/mod-resolver/issue-5063/main.rs" ,
38+ & [
39+ "tests/mod-resolver/issue-5063/foo/bar/baz.rs" ,
40+ "tests/mod-resolver/issue-5063/foo.rs" ,
41+ ] ,
42+ ) ;
2543}
0 commit comments