1
1
//! Tidy check to ensure below in UI test directories:
2
- //! - the number of entries in each directory must be less than `ENTRY_LIMIT`
3
2
//! - there are no stray `.stderr` files
4
3
5
- use std:: collections:: { BTreeSet , HashMap } ;
4
+ use std:: collections:: BTreeSet ;
6
5
use std:: ffi:: OsStr ;
7
6
use std:: fs;
8
7
use std:: io:: Write ;
9
8
use std:: path:: { Path , PathBuf } ;
10
9
11
- use ignore:: Walk ;
12
-
13
- // FIXME: GitHub's UI truncates file lists that exceed 1000 entries, so these
14
- // should all be 1000 or lower. Limits significantly smaller than 1000 are also
15
- // desirable, because large numbers of files are unwieldy in general. See issue
16
- // #73494.
17
- const ENTRY_LIMIT : u32 = 901 ;
18
- // FIXME: The following limits should be reduced eventually.
19
-
20
- const ISSUES_ENTRY_LIMIT : u32 = 1616 ;
21
-
22
10
const EXPECTED_TEST_FILE_EXTENSIONS : & [ & str ] = & [
23
11
"rs" , // test source files
24
12
"stderr" , // expected stderr file, corresponds to a rs file
@@ -54,50 +42,13 @@ const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
54
42
"tests/ui/std/windows-bat-args3.bat" , // tests escaping arguments through batch files
55
43
] ;
56
44
57
- fn check_entries ( tests_path : & Path , bad : & mut bool ) {
58
- let mut directories: HashMap < PathBuf , u32 > = HashMap :: new ( ) ;
59
-
60
- for entry in Walk :: new ( tests_path. join ( "ui" ) ) . flatten ( ) {
61
- let parent = entry. path ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ;
62
- * directories. entry ( parent) . or_default ( ) += 1 ;
63
- }
64
-
65
- let ( mut max, mut max_issues) = ( 0 , 0 ) ;
66
- for ( dir_path, count) in directories {
67
- let is_issues_dir = tests_path. join ( "ui/issues" ) == dir_path;
68
- let ( limit, maxcnt) = if is_issues_dir {
69
- ( ISSUES_ENTRY_LIMIT , & mut max_issues)
70
- } else {
71
- ( ENTRY_LIMIT , & mut max)
72
- } ;
73
- * maxcnt = ( * maxcnt) . max ( count) ;
74
- if count > limit {
75
- tidy_error ! (
76
- bad,
77
- "following path contains more than {} entries, \
78
- you should move the test to some relevant subdirectory (current: {}): {}",
79
- limit,
80
- count,
81
- dir_path. display( )
82
- ) ;
83
- }
84
- }
85
- if ISSUES_ENTRY_LIMIT > max_issues {
86
- tidy_error ! (
87
- bad,
88
- "`ISSUES_ENTRY_LIMIT` is too high (is {ISSUES_ENTRY_LIMIT}, should be {max_issues})"
89
- ) ;
90
- }
91
- }
92
-
93
45
pub fn check ( root_path : & Path , bless : bool , bad : & mut bool ) {
94
46
let issues_txt_header = r#"============================================================
95
47
⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️
96
48
============================================================
97
49
"# ;
98
50
99
51
let path = & root_path. join ( "tests" ) ;
100
- check_entries ( path, bad) ;
101
52
102
53
// the list of files in ui tests that are allowed to start with `issue-XXXX`
103
54
// BTreeSet because we would like a stable ordering so --bless works
@@ -124,7 +75,11 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
124
75
) ;
125
76
}
126
77
127
- let mut remaining_issue_names: BTreeSet < & str > = allowed_issue_names. clone ( ) ;
78
+ let mut remaining_issue_names: BTreeSet < & str > = allowed_issue_names
79
+ . clone ( )
80
+ . into_iter ( )
81
+ . filter ( |name| !name. starts_with ( "ui/issues/" ) )
82
+ . collect ( ) ;
128
83
129
84
let ( ui, ui_fulldeps) = ( path. join ( "ui" ) , path. join ( "ui-fulldeps" ) ) ;
130
85
let paths = [ ui. as_path ( ) , ui_fulldeps. as_path ( ) ] ;
@@ -179,7 +134,9 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
179
134
. unwrap ( )
180
135
. replace ( std:: path:: MAIN_SEPARATOR_STR , "/" ) ;
181
136
182
- if !remaining_issue_names. remove ( stripped_path. as_str ( ) ) {
137
+ if !remaining_issue_names. remove ( stripped_path. as_str ( ) )
138
+ && !stripped_path. starts_with ( "ui/issues/" )
139
+ {
183
140
tidy_error ! (
184
141
bad,
185
142
"file `tests/{stripped_path}` must begin with a descriptive name, consider `{{reason}}-issue-{issue_n}.rs`" ,
0 commit comments