@@ -7,7 +7,9 @@ use std::path::PathBuf;
7
7
use std:: process:: Command ;
8
8
use std:: process:: ExitCode ;
9
9
10
- use String as LintError ;
10
+ type LintError = String ;
11
+ type LintResult = Result < ( ) , LintError > ;
12
+ type LintFn = fn ( ) -> LintResult ;
11
13
12
14
/// Return the git command
13
15
fn git ( ) -> Command {
@@ -31,7 +33,31 @@ fn get_git_root() -> String {
31
33
check_output ( git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) . unwrap ( )
32
34
}
33
35
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 {
35
61
let found = git ( )
36
62
. args ( [
37
63
"grep" ,
@@ -55,8 +81,37 @@ fs:: namespace, which has unsafe filesystem functions marked as deleted.
55
81
}
56
82
}
57
83
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
+
58
108
fn 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
+ ] ;
60
115
61
116
let git_root = PathBuf :: from ( get_git_root ( ) ) ;
62
117
0 commit comments