3
3
use std:: collections:: HashSet ;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
6
- fn check_unused_files ( path : & Path , bad : & mut bool ) {
6
+ fn check_unused_files ( path : & Path , bless : bool , bad : & mut bool ) {
7
7
let mut rs_files = Vec :: < PathBuf > :: new ( ) ;
8
8
let mut output_files = HashSet :: < PathBuf > :: new ( ) ;
9
9
let files = walkdir:: WalkDir :: new ( & path. join ( "test/mir-opt" ) ) . into_iter ( ) ;
@@ -27,11 +27,15 @@ fn check_unused_files(path: &Path, bad: &mut bool) {
27
27
28
28
for extra in output_files {
29
29
if extra. file_name ( ) != Some ( "README.md" . as_ref ( ) ) {
30
- tidy_error ! (
31
- bad,
32
- "the following output file is not associated with any mir-opt test, you can remove it: {}" ,
33
- extra. display( )
34
- ) ;
30
+ if !bless {
31
+ tidy_error ! (
32
+ bad,
33
+ "the following output file is not associated with any mir-opt test, you can remove it: {}" ,
34
+ extra. display( )
35
+ ) ;
36
+ } else {
37
+ let _ = std:: fs:: remove_file ( extra) ;
38
+ }
35
39
}
36
40
}
37
41
}
@@ -65,6 +69,6 @@ fn check_dash_files(path: &Path, bless: bool, bad: &mut bool) {
65
69
}
66
70
67
71
pub fn check ( path : & Path , bless : bool , bad : & mut bool ) {
68
- check_unused_files ( path, bad) ;
72
+ check_unused_files ( path, bless , bad) ;
69
73
check_dash_files ( path, bless, bad) ;
70
74
}
0 commit comments