@@ -7,7 +7,9 @@ use std::path::PathBuf;
77use std:: process:: Command ;
88use std:: process:: ExitCode ;
99
10- use String as LintError ;
10+ type LintError = String ;
11+ type LintResult = Result < ( ) , LintError > ;
12+ type LintFn = fn ( ) -> LintResult ;
1113
1214/// Return the git command
1315fn git ( ) -> Command {
@@ -31,7 +33,31 @@ fn get_git_root() -> String {
3133 check_output ( git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) . unwrap ( )
3234}
3335
34- fn lint_std_filesystem ( ) -> Result < ( ) , LintError > {
36+ fn lint_subtree ( ) -> LintResult {
37+ // This only checks that the trees are pure subtrees, it is not doing a full
38+ // check with -r to not have to fetch all the remotes.
39+ let mut good = true ;
40+ for subtree in [
41+ "src/crypto/ctaes" ,
42+ "src/secp256k1" ,
43+ "src/minisketch" ,
44+ "src/leveldb" ,
45+ "src/crc32c" ,
46+ ] {
47+ good &= Command :: new ( "test/lint/git-subtree-check.sh" )
48+ . arg ( subtree)
49+ . status ( )
50+ . expect ( "command_error" )
51+ . success ( ) ;
52+ }
53+ if good {
54+ Ok ( ( ) )
55+ } else {
56+ Err ( "" . to_string ( ) )
57+ }
58+ }
59+
60+ fn lint_std_filesystem ( ) -> LintResult {
3561 let found = git ( )
3662 . args ( [
3763 "grep" ,
@@ -55,8 +81,37 @@ fs:: namespace, which has unsafe filesystem functions marked as deleted.
5581 }
5682}
5783
84+ fn lint_doc ( ) -> LintResult {
85+ if Command :: new ( "test/lint/check-doc.py" )
86+ . status ( )
87+ . expect ( "command error" )
88+ . success ( )
89+ {
90+ Ok ( ( ) )
91+ } else {
92+ Err ( "" . to_string ( ) )
93+ }
94+ }
95+
96+ fn lint_all ( ) -> LintResult {
97+ if Command :: new ( "test/lint/all-lint.py" )
98+ . status ( )
99+ . expect ( "command error" )
100+ . success ( )
101+ {
102+ Ok ( ( ) )
103+ } else {
104+ Err ( "" . to_string ( ) )
105+ }
106+ }
107+
58108fn main ( ) -> ExitCode {
59- let test_list = [ ( "std::filesystem check" , lint_std_filesystem) ] ;
109+ let test_list: Vec < ( & str , LintFn ) > = vec ! [
110+ ( "subtree check" , lint_subtree) ,
111+ ( "std::filesystem check" , lint_std_filesystem) ,
112+ ( "-help=1 documentation check" , lint_doc) ,
113+ ( "all-lint.py script" , lint_all) ,
114+ ] ;
60115
61116 let git_root = PathBuf :: from ( get_git_root ( ) ) ;
62117
0 commit comments