diff options
Diffstat (limited to 'xtask/tests')
-rw-r--r-- | xtask/tests/tidy.rs | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 2e9fcf07c..62626064e 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -31,6 +31,13 @@ fn generated_assists_are_fresh() { | |||
31 | } | 31 | } |
32 | 32 | ||
33 | #[test] | 33 | #[test] |
34 | fn generated_features_are_fresh() { | ||
35 | if let Err(error) = codegen::generate_feature_docs(Mode::Verify) { | ||
36 | panic!("{}. Please update features by running `cargo xtask codegen`", error); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | #[test] | ||
34 | fn check_code_formatting() { | 41 | fn check_code_formatting() { |
35 | if let Err(error) = run_rustfmt(Mode::Verify) { | 42 | if let Err(error) = run_rustfmt(Mode::Verify) { |
36 | panic!("{}. Please format the code by running `cargo format`", error); | 43 | panic!("{}. Please format the code by running `cargo format`", error); |
@@ -95,7 +102,7 @@ impl TidyDocs { | |||
95 | fn visit(&mut self, path: &Path, text: &str) { | 102 | fn visit(&mut self, path: &Path, text: &str) { |
96 | // Test hopefully don't really need comments, and for assists we already | 103 | // Test hopefully don't really need comments, and for assists we already |
97 | // have special comments which are source of doc tests and user docs. | 104 | // have special comments which are source of doc tests and user docs. |
98 | if is_exclude_dir(path, &["tests", "test_data", "handlers"]) { | 105 | if is_exclude_dir(path, &["tests", "test_data"]) { |
99 | return; | 106 | return; |
100 | } | 107 | } |
101 | 108 | ||
@@ -110,9 +117,12 @@ impl TidyDocs { | |||
110 | 117 | ||
111 | if first_line.starts_with("//!") { | 118 | if first_line.starts_with("//!") { |
112 | if first_line.contains("FIXME") { | 119 | if first_line.contains("FIXME") { |
113 | self.contains_fixme.push(path.to_path_buf()) | 120 | self.contains_fixme.push(path.to_path_buf()); |
114 | } | 121 | } |
115 | } else { | 122 | } else { |
123 | if text.contains("// Feature:") || text.contains("// Assist:") { | ||
124 | return; | ||
125 | } | ||
116 | self.missing_docs.push(path.display().to_string()); | 126 | self.missing_docs.push(path.display().to_string()); |
117 | } | 127 | } |
118 | 128 | ||
@@ -170,13 +180,11 @@ impl TidyDocs { | |||
170 | } | 180 | } |
171 | 181 | ||
172 | fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool { | 182 | fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool { |
173 | let mut cur_path = p; | 183 | p.strip_prefix(project_root()) |
174 | while let Some(path) = cur_path.parent() { | 184 | .unwrap() |
175 | if dirs_to_exclude.iter().any(|dir| path.ends_with(dir)) { | 185 | .components() |
176 | return true; | 186 | .rev() |
177 | } | 187 | .skip(1) |
178 | cur_path = path; | 188 | .filter_map(|it| it.as_os_str().to_str()) |
179 | } | 189 | .any(|it| dirs_to_exclude.contains(&it)) |
180 | |||
181 | false | ||
182 | } | 190 | } |