3
3
// file COPYING or https://opensource.org/license/mit/.
4
4
5
5
use std:: env;
6
+ use std:: fs;
6
7
use std:: path:: PathBuf ;
7
8
use std:: process:: Command ;
8
9
use std:: process:: ExitCode ;
@@ -29,8 +30,8 @@ fn check_output(cmd: &mut std::process::Command) -> Result<String, LintError> {
29
30
}
30
31
31
32
/// Return the git root as utf8, or panic
32
- fn get_git_root ( ) -> String {
33
- check_output ( git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) . unwrap ( )
33
+ fn get_git_root ( ) -> PathBuf {
34
+ PathBuf :: from ( check_output ( git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) . unwrap ( ) )
34
35
}
35
36
36
37
fn lint_subtree ( ) -> LintResult {
@@ -94,11 +95,24 @@ fn lint_doc() -> LintResult {
94
95
}
95
96
96
97
fn lint_all ( ) -> LintResult {
97
- if Command :: new ( "test/lint/all-lint.py" )
98
- . status ( )
99
- . expect ( "command error" )
100
- . success ( )
101
- {
98
+ let mut good = true ;
99
+ let lint_dir = get_git_root ( ) . join ( "test/lint" ) ;
100
+ for entry in fs:: read_dir ( lint_dir) . unwrap ( ) {
101
+ let entry = entry. unwrap ( ) ;
102
+ let entry_fn = entry. file_name ( ) . into_string ( ) . unwrap ( ) ;
103
+ if entry_fn. starts_with ( "lint-" )
104
+ && entry_fn. ends_with ( ".py" )
105
+ && !Command :: new ( "python3" )
106
+ . arg ( entry. path ( ) )
107
+ . status ( )
108
+ . expect ( "command error" )
109
+ . success ( )
110
+ {
111
+ good = false ;
112
+ println ! ( "^---- failure generated from {}" , entry_fn) ;
113
+ }
114
+ }
115
+ if good {
102
116
Ok ( ( ) )
103
117
} else {
104
118
Err ( "" . to_string ( ) )
@@ -110,10 +124,10 @@ fn main() -> ExitCode {
110
124
( "subtree check" , lint_subtree) ,
111
125
( "std::filesystem check" , lint_std_filesystem) ,
112
126
( "-help=1 documentation check" , lint_doc) ,
113
- ( "all- lint.py script " , lint_all) ,
127
+ ( "lint-* .py scripts " , lint_all) ,
114
128
] ;
115
129
116
- let git_root = PathBuf :: from ( get_git_root ( ) ) ;
130
+ let git_root = get_git_root ( ) ;
117
131
118
132
let mut test_failed = false ;
119
133
for ( lint_name, lint_fn) in test_list {
0 commit comments