@@ -6,23 +6,29 @@ use std::{
6
6
7
7
use xshell:: Shell ;
8
8
9
- #[ cfg( not( feature = "in-rust-tree" ) ) ]
10
9
use xshell:: cmd;
11
10
12
- #[ test]
13
- fn check_lsp_extensions_docs ( ) {
14
- let sh = & Shell :: new ( ) . unwrap ( ) ;
11
+ use crate :: { flags:: Tidy , project_root, util:: list_files} ;
15
12
13
+ impl Tidy {
14
+ pub ( crate ) fn run ( & self , sh : & Shell ) -> anyhow:: Result < ( ) > {
15
+ check_lsp_extensions_docs ( sh) ;
16
+ files_are_tidy ( sh) ;
17
+ check_licenses ( sh) ;
18
+ Ok ( ( ) )
19
+ }
20
+ }
21
+
22
+ fn check_lsp_extensions_docs ( sh : & Shell ) {
16
23
let expected_hash = {
17
- let lsp_ext_rs = sh
18
- . read_file ( sourcegen:: project_root ( ) . join ( "crates/rust-analyzer/src/lsp/ext.rs" ) )
19
- . unwrap ( ) ;
24
+ let lsp_ext_rs =
25
+ sh. read_file ( project_root ( ) . join ( "crates/rust-analyzer/src/lsp/ext.rs" ) ) . unwrap ( ) ;
20
26
stable_hash ( lsp_ext_rs. as_str ( ) )
21
27
} ;
22
28
23
29
let actual_hash = {
24
30
let lsp_extensions_md =
25
- sh. read_file ( sourcegen :: project_root ( ) . join ( "docs/dev/lsp-extensions.md" ) ) . unwrap ( ) ;
31
+ sh. read_file ( project_root ( ) . join ( "docs/dev/lsp-extensions.md" ) ) . unwrap ( ) ;
26
32
let text = lsp_extensions_md
27
33
. lines ( )
28
34
. find_map ( |line| line. strip_prefix ( "lsp/ext.rs hash:" ) )
@@ -45,11 +51,8 @@ Please adjust docs/dev/lsp-extensions.md.
45
51
}
46
52
}
47
53
48
- #[ test]
49
- fn files_are_tidy ( ) {
50
- let sh = & Shell :: new ( ) . unwrap ( ) ;
51
-
52
- let files = sourcegen:: list_files ( & sourcegen:: project_root ( ) . join ( "crates" ) ) ;
54
+ fn files_are_tidy ( sh : & Shell ) {
55
+ let files = list_files ( & project_root ( ) . join ( "crates" ) ) ;
53
56
54
57
let mut tidy_docs = TidyDocs :: default ( ) ;
55
58
let mut tidy_marks = TidyMarks :: default ( ) ;
@@ -121,11 +124,7 @@ fn check_cargo_toml(path: &Path, text: String) {
121
124
}
122
125
}
123
126
124
- #[ cfg( not( feature = "in-rust-tree" ) ) ]
125
- #[ test]
126
- fn check_licenses ( ) {
127
- let sh = & Shell :: new ( ) . unwrap ( ) ;
128
-
127
+ fn check_licenses ( sh : & Shell ) {
129
128
let expected = "
130
129
(MIT OR Apache-2.0) AND Unicode-DFS-2016
131
130
0BSD OR MIT OR Apache-2.0
@@ -277,7 +276,7 @@ impl TidyDocs {
277
276
}
278
277
279
278
fn is_exclude_dir ( p : & Path , dirs_to_exclude : & [ & str ] ) -> bool {
280
- p. strip_prefix ( sourcegen :: project_root ( ) )
279
+ p. strip_prefix ( project_root ( ) )
281
280
. unwrap ( )
282
281
. components ( )
283
282
. rev ( )
0 commit comments