diff options
Diffstat (limited to 'xtask/tests')
-rw-r--r-- | xtask/tests/tidy.rs | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index f99935170..ca14e8ac1 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -5,7 +5,7 @@ use std::{ | |||
5 | 5 | ||
6 | use xtask::{ | 6 | use xtask::{ |
7 | codegen::{self, Mode}, | 7 | codegen::{self, Mode}, |
8 | not_bash::fs2, | 8 | not_bash::{fs2, run}, |
9 | project_root, run_rustfmt, rust_files, | 9 | project_root, run_rustfmt, rust_files, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -49,19 +49,58 @@ fn rust_files_are_tidy() { | |||
49 | tidy_docs.finish(); | 49 | tidy_docs.finish(); |
50 | } | 50 | } |
51 | 51 | ||
52 | #[test] | ||
53 | fn check_licenses() { | ||
54 | let expected = " | ||
55 | 0BSD OR MIT OR Apache-2.0 | ||
56 | Apache-2.0 | ||
57 | Apache-2.0 OR BSL-1.0 | ||
58 | Apache-2.0 OR MIT | ||
59 | Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT | ||
60 | Apache-2.0/MIT | ||
61 | BSD-2-Clause | ||
62 | BSD-3-Clause | ||
63 | CC0-1.0 | ||
64 | ISC | ||
65 | MIT | ||
66 | MIT / Apache-2.0 | ||
67 | MIT OR Apache-2.0 | ||
68 | MIT/Apache-2.0 | ||
69 | MIT/Apache-2.0 AND BSD-2-Clause | ||
70 | Unlicense OR MIT | ||
71 | Unlicense/MIT | ||
72 | Zlib | ||
73 | " | ||
74 | .lines() | ||
75 | .filter(|it| !it.is_empty()) | ||
76 | .collect::<Vec<_>>(); | ||
77 | |||
78 | let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap(); | ||
79 | let mut licenses = meta | ||
80 | .split(|c| c == ',' || c == '{' || c == '}') | ||
81 | .filter(|it| it.contains(r#""license""#)) | ||
82 | .map(|it| it.trim()) | ||
83 | .map(|it| it[r#""license":"#.len()..].trim_matches('"')) | ||
84 | .collect::<Vec<_>>(); | ||
85 | licenses.sort(); | ||
86 | licenses.dedup(); | ||
87 | assert_eq!(licenses, expected); | ||
88 | } | ||
89 | |||
52 | fn check_todo(path: &Path, text: &str) { | 90 | fn check_todo(path: &Path, text: &str) { |
53 | let whitelist = &[ | 91 | let need_todo = &[ |
54 | // This file itself is whitelisted since this test itself contains matches. | 92 | // This file itself obviously needs to use todo (<- like this!). |
55 | "tests/cli.rs", | 93 | "tests/cli.rs", |
56 | // Some of our assists generate `todo!()` so those files are whitelisted. | 94 | // Some of our assists generate `todo!()`. |
57 | "tests/generated.rs", | 95 | "tests/generated.rs", |
58 | "handlers/add_missing_impl_members.rs", | 96 | "handlers/add_missing_impl_members.rs", |
59 | "handlers/add_turbo_fish.rs", | 97 | "handlers/add_turbo_fish.rs", |
60 | "handlers/generate_function.rs", | 98 | "handlers/generate_function.rs", |
61 | // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make. | 99 | // To support generating `todo!()` in assists, we have `expr_todo()` in |
100 | // `ast::make`. | ||
62 | "ast/make.rs", | 101 | "ast/make.rs", |
63 | ]; | 102 | ]; |
64 | if whitelist.iter().any(|p| path.ends_with(p)) { | 103 | if need_todo.iter().any(|p| path.ends_with(p)) { |
65 | return; | 104 | return; |
66 | } | 105 | } |
67 | if text.contains("TODO") || text.contains("TOOD") || text.contains("todo!") { | 106 | if text.contains("TODO") || text.contains("TOOD") || text.contains("todo!") { |
@@ -139,7 +178,7 @@ impl TidyDocs { | |||
139 | ) | 178 | ) |
140 | } | 179 | } |
141 | 180 | ||
142 | let whitelist = [ | 181 | let poorly_documented = [ |
143 | "ra_hir", | 182 | "ra_hir", |
144 | "ra_hir_expand", | 183 | "ra_hir_expand", |
145 | "ra_ide", | 184 | "ra_ide", |
@@ -153,9 +192,9 @@ impl TidyDocs { | |||
153 | ]; | 192 | ]; |
154 | 193 | ||
155 | let mut has_fixmes = | 194 | let mut has_fixmes = |
156 | whitelist.iter().map(|it| (*it, false)).collect::<HashMap<&str, bool>>(); | 195 | poorly_documented.iter().map(|it| (*it, false)).collect::<HashMap<&str, bool>>(); |
157 | 'outer: for path in self.contains_fixme { | 196 | 'outer: for path in self.contains_fixme { |
158 | for krate in whitelist.iter() { | 197 | for krate in poorly_documented.iter() { |
159 | if path.components().any(|it| it.as_os_str() == *krate) { | 198 | if path.components().any(|it| it.as_os_str() == *krate) { |
160 | has_fixmes.insert(krate, true); | 199 | has_fixmes.insert(krate, true); |
161 | continue 'outer; | 200 | continue 'outer; |
@@ -166,7 +205,7 @@ impl TidyDocs { | |||
166 | 205 | ||
167 | for (krate, has_fixme) in has_fixmes.iter() { | 206 | for (krate, has_fixme) in has_fixmes.iter() { |
168 | if !has_fixme { | 207 | if !has_fixme { |
169 | panic!("crate {} is fully documented, remove it from the white list", krate) | 208 | panic!("crate {} is fully documented :tada:, remove it from the list of poorly documented crates", krate) |
170 | } | 209 | } |
171 | } | 210 | } |
172 | } | 211 | } |