@@ -7,41 +7,6 @@ use std::fs;
7
7
use std:: io:: Write ;
8
8
use std:: path:: { Path , PathBuf } ;
9
9
10
- const EXPECTED_TEST_FILE_EXTENSIONS : & [ & str ] = & [
11
- "rs" , // test source files
12
- "stderr" , // expected stderr file, corresponds to a rs file
13
- "svg" , // expected svg file, corresponds to a rs file, equivalent to stderr
14
- "stdout" , // expected stdout file, corresponds to a rs file
15
- "fixed" , // expected source file after applying fixes
16
- "md" , // test directory descriptions
17
- "ftl" , // translation tests
18
- ] ;
19
-
20
- const EXTENSION_EXCEPTION_PATHS : & [ & str ] = & [
21
- "tests/ui/asm/named-asm-labels.s" , // loading an external asm file to test named labels lint
22
- "tests/ui/codegen/mismatched-data-layout.json" , // testing mismatched data layout w/ custom targets
23
- "tests/ui/check-cfg/my-awesome-platform.json" , // testing custom targets with cfgs
24
- "tests/ui/argfile/commandline-argfile-badutf8.args" , // passing args via a file
25
- "tests/ui/argfile/commandline-argfile.args" , // passing args via a file
26
- "tests/ui/crate-loading/auxiliary/libfoo.rlib" , // testing loading a manually created rlib
27
- "tests/ui/include-macros/data.bin" , // testing including data with the include macros
28
- "tests/ui/include-macros/file.txt" , // testing including data with the include macros
29
- "tests/ui/macros/macro-expanded-include/file.txt" , // testing including data with the include macros
30
- "tests/ui/macros/not-utf8.bin" , // testing including data with the include macros
31
- "tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment" , // more include
32
- "tests/ui/proc-macro/auxiliary/included-file.txt" , // more include
33
- "tests/ui/unpretty/auxiliary/data.txt" , // more include
34
- "tests/ui/invalid/foo.natvis.xml" , // sample debugger visualizer
35
- "tests/ui/sanitizer/dataflow-abilist.txt" , // dataflow sanitizer ABI list file
36
- "tests/ui/shell-argfiles/shell-argfiles.args" , // passing args via a file
37
- "tests/ui/shell-argfiles/shell-argfiles-badquotes.args" , // passing args via a file
38
- "tests/ui/shell-argfiles/shell-argfiles-via-argfile-shell.args" , // passing args via a file
39
- "tests/ui/shell-argfiles/shell-argfiles-via-argfile.args" , // passing args via a file
40
- "tests/ui/std/windows-bat-args1.bat" , // tests escaping arguments through batch files
41
- "tests/ui/std/windows-bat-args2.bat" , // tests escaping arguments through batch files
42
- "tests/ui/std/windows-bat-args3.bat" , // tests escaping arguments through batch files
43
- ] ;
44
-
45
10
pub fn check ( root_path : & Path , bless : bool , bad : & mut bool ) {
46
11
let issues_txt_header = r#"============================================================
47
12
⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️
@@ -82,13 +47,7 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
82
47
crate :: walk:: walk_no_read ( & paths, |_, _| false , & mut |entry| {
83
48
let file_path = entry. path ( ) ;
84
49
if let Some ( ext) = file_path. extension ( ) . and_then ( OsStr :: to_str) {
85
- // files that are neither an expected extension or an exception should not exist
86
- // they're probably typos or not meant to exist
87
- if !( EXPECTED_TEST_FILE_EXTENSIONS . contains ( & ext)
88
- || EXTENSION_EXCEPTION_PATHS . iter ( ) . any ( |path| file_path. ends_with ( path) ) )
89
- {
90
- tidy_error ! ( bad, "file {} has unexpected extension {}" , file_path. display( ) , ext) ;
91
- }
50
+ check_unexpected_extension ( bad, file_path, ext) ;
92
51
93
52
// NB: We do not use file_stem() as some file names have multiple `.`s and we
94
53
// must strip all of them.
@@ -171,3 +130,48 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
171
130
}
172
131
}
173
132
}
133
+
134
+ fn check_unexpected_extension ( bad : & mut bool , file_path : & Path , ext : & str ) {
135
+ const EXPECTED_TEST_FILE_EXTENSIONS : & [ & str ] = & [
136
+ "rs" , // test source files
137
+ "stderr" , // expected stderr file, corresponds to a rs file
138
+ "svg" , // expected svg file, corresponds to a rs file, equivalent to stderr
139
+ "stdout" , // expected stdout file, corresponds to a rs file
140
+ "fixed" , // expected source file after applying fixes
141
+ "md" , // test directory descriptions
142
+ "ftl" , // translation tests
143
+ ] ;
144
+
145
+ const EXTENSION_EXCEPTION_PATHS : & [ & str ] = & [
146
+ "tests/ui/asm/named-asm-labels.s" , // loading an external asm file to test named labels lint
147
+ "tests/ui/codegen/mismatched-data-layout.json" , // testing mismatched data layout w/ custom targets
148
+ "tests/ui/check-cfg/my-awesome-platform.json" , // testing custom targets with cfgs
149
+ "tests/ui/argfile/commandline-argfile-badutf8.args" , // passing args via a file
150
+ "tests/ui/argfile/commandline-argfile.args" , // passing args via a file
151
+ "tests/ui/crate-loading/auxiliary/libfoo.rlib" , // testing loading a manually created rlib
152
+ "tests/ui/include-macros/data.bin" , // testing including data with the include macros
153
+ "tests/ui/include-macros/file.txt" , // testing including data with the include macros
154
+ "tests/ui/macros/macro-expanded-include/file.txt" , // testing including data with the include macros
155
+ "tests/ui/macros/not-utf8.bin" , // testing including data with the include macros
156
+ "tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment" , // more include
157
+ "tests/ui/proc-macro/auxiliary/included-file.txt" , // more include
158
+ "tests/ui/unpretty/auxiliary/data.txt" , // more include
159
+ "tests/ui/invalid/foo.natvis.xml" , // sample debugger visualizer
160
+ "tests/ui/sanitizer/dataflow-abilist.txt" , // dataflow sanitizer ABI list file
161
+ "tests/ui/shell-argfiles/shell-argfiles.args" , // passing args via a file
162
+ "tests/ui/shell-argfiles/shell-argfiles-badquotes.args" , // passing args via a file
163
+ "tests/ui/shell-argfiles/shell-argfiles-via-argfile-shell.args" , // passing args via a file
164
+ "tests/ui/shell-argfiles/shell-argfiles-via-argfile.args" , // passing args via a file
165
+ "tests/ui/std/windows-bat-args1.bat" , // tests escaping arguments through batch files
166
+ "tests/ui/std/windows-bat-args2.bat" , // tests escaping arguments through batch files
167
+ "tests/ui/std/windows-bat-args3.bat" , // tests escaping arguments through batch files
168
+ ] ;
169
+
170
+ // files that are neither an expected extension or an exception should not exist
171
+ // they're probably typos or not meant to exist
172
+ if !( EXPECTED_TEST_FILE_EXTENSIONS . contains ( & ext)
173
+ || EXTENSION_EXCEPTION_PATHS . iter ( ) . any ( |path| file_path. ends_with ( path) ) )
174
+ {
175
+ tidy_error ! ( bad, "file {} has unexpected extension {}" , file_path. display( ) , ext) ;
176
+ }
177
+ }
0 commit comments