@@ -100,25 +100,41 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
100
100
}
101
101
102
102
pub fn check ( root_path : & Path , bless : bool , bad : & mut bool ) {
103
+ let issues_txt_header = r#"============================================================
104
+ ⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️
105
+ ============================================================
106
+ "# ;
107
+
103
108
let path = & root_path. join ( "tests" ) ;
104
109
check_entries ( & path, bad) ;
105
110
106
111
// the list of files in ui tests that are allowed to start with `issue-XXXX`
107
112
// BTreeSet because we would like a stable ordering so --bless works
108
- let issues_list =
109
- include ! ( "issues.txt" ) . map ( |path| path. replace ( "/" , std:: path:: MAIN_SEPARATOR_STR ) ) ;
110
- let issues: Vec < String > = Vec :: from ( issues_list. clone ( ) ) ;
111
- let is_sorted = issues. windows ( 2 ) . all ( |w| w[ 0 ] < w[ 1 ] ) ;
113
+ let mut prev_line = "" ;
114
+ let mut is_sorted = true ;
115
+ let allowed_issue_names: BTreeSet < _ > = include_str ! ( "issues.txt" )
116
+ . strip_prefix ( issues_txt_header)
117
+ . unwrap ( )
118
+ . lines ( )
119
+ . map ( |line| {
120
+ if prev_line > line {
121
+ is_sorted = false ;
122
+ }
123
+
124
+ prev_line = line;
125
+ line
126
+ } )
127
+ . collect ( ) ;
128
+
112
129
if !is_sorted && !bless {
113
130
tidy_error ! (
114
131
bad,
115
132
"`src/tools/tidy/src/issues.txt` is not in order, mostly because you modified it manually,
116
133
please only update it with command `x test tidy --bless`"
117
134
) ;
118
135
}
119
- let allowed_issue_names = BTreeSet :: from ( issues_list) ;
120
136
121
- let mut remaining_issue_names: BTreeSet < String > = allowed_issue_names. clone ( ) ;
137
+ let mut remaining_issue_names: BTreeSet < & str > = allowed_issue_names. clone ( ) ;
122
138
123
139
let ( ui, ui_fulldeps) = ( path. join ( "ui" ) , path. join ( "ui-fulldeps" ) ) ;
124
140
let paths = [ ui. as_path ( ) , ui_fulldeps. as_path ( ) ] ;
@@ -186,15 +202,7 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
186
202
// if there are any file names remaining, they were moved on the fs.
187
203
// our data must remain up to date, so it must be removed from issues.txt
188
204
// do this automatically on bless, otherwise issue a tidy error
189
- if bless && !remaining_issue_names. is_empty ( ) {
190
- let issues_txt_header = r#"
191
- /*
192
- ============================================================
193
- ⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️
194
- ============================================================
195
- */
196
- [
197
- "# ;
205
+ if bless && ( !remaining_issue_names. is_empty ( ) || !is_sorted) {
198
206
let tidy_src = root_path. join ( "src/tools/tidy/src" ) ;
199
207
// instead of overwriting the file, recreate it and use an "atomic rename"
200
208
// so we don't bork things on panic or a contributor using Ctrl+C
@@ -206,9 +214,8 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
206
214
. difference ( & remaining_issue_names)
207
215
. map ( |s| s. replace ( std:: path:: MAIN_SEPARATOR_STR , "/" ) )
208
216
{
209
- write ! ( blessed_issues_txt, "\" {filename}\" , \n " ) . unwrap ( ) ;
217
+ writeln ! ( blessed_issues_txt, "{filename}" ) . unwrap ( ) ;
210
218
}
211
- write ! ( blessed_issues_txt, "]\n " ) . unwrap ( ) ;
212
219
let old_issues_path = tidy_src. join ( "issues.txt" ) ;
213
220
fs:: rename ( blessed_issues_path, old_issues_path) . unwrap ( ) ;
214
221
} else {
0 commit comments