diff options
author | Zac Pullar-Strecker <[email protected]> | 2020-07-31 03:12:44 +0100 |
---|---|---|
committer | Zac Pullar-Strecker <[email protected]> | 2020-07-31 03:12:44 +0100 |
commit | f05d7b41a719d848844b054a16477b29d0f063c6 (patch) | |
tree | 0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /xtask/tests/tidy.rs | |
parent | 73ff610e41959e3e7c78a2b4b25b086883132956 (diff) | |
parent | 6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff) |
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'xtask/tests/tidy.rs')
-rw-r--r-- | xtask/tests/tidy.rs | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index d38ac7f17..d65a2acbc 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,56 @@ 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 OR BSL-1.0 | ||
57 | Apache-2.0 OR MIT | ||
58 | Apache-2.0/MIT | ||
59 | BSD-2-Clause | ||
60 | BSD-3-Clause | ||
61 | CC0-1.0 | ||
62 | ISC | ||
63 | MIT | ||
64 | MIT / Apache-2.0 | ||
65 | MIT OR Apache-2.0 | ||
66 | MIT/Apache-2.0 | ||
67 | MIT/Apache-2.0 AND BSD-2-Clause | ||
68 | Unlicense OR MIT | ||
69 | Unlicense/MIT | ||
70 | Zlib | ||
71 | " | ||
72 | .lines() | ||
73 | .filter(|it| !it.is_empty()) | ||
74 | .collect::<Vec<_>>(); | ||
75 | |||
76 | let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap(); | ||
77 | let mut licenses = meta | ||
78 | .split(|c| c == ',' || c == '{' || c == '}') | ||
79 | .filter(|it| it.contains(r#""license""#)) | ||
80 | .map(|it| it.trim()) | ||
81 | .map(|it| it[r#""license":"#.len()..].trim_matches('"')) | ||
82 | .collect::<Vec<_>>(); | ||
83 | licenses.sort(); | ||
84 | licenses.dedup(); | ||
85 | assert_eq!(licenses, expected); | ||
86 | } | ||
87 | |||
52 | fn check_todo(path: &Path, text: &str) { | 88 | fn check_todo(path: &Path, text: &str) { |
53 | let whitelist = &[ | 89 | let need_todo = &[ |
54 | // This file itself is whitelisted since this test itself contains matches. | 90 | // This file itself obviously needs to use todo (<- like this!). |
55 | "tests/cli.rs", | 91 | "tests/cli.rs", |
56 | // Some of our assists generate `todo!()` so those files are whitelisted. | 92 | // Some of our assists generate `todo!()`. |
57 | "tests/generated.rs", | 93 | "tests/generated.rs", |
58 | "handlers/add_missing_impl_members.rs", | 94 | "handlers/add_missing_impl_members.rs", |
59 | "handlers/add_function.rs", | ||
60 | "handlers/add_turbo_fish.rs", | 95 | "handlers/add_turbo_fish.rs", |
61 | // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make. | 96 | "handlers/generate_function.rs", |
97 | // To support generating `todo!()` in assists, we have `expr_todo()` in | ||
98 | // `ast::make`. | ||
62 | "ast/make.rs", | 99 | "ast/make.rs", |
63 | ]; | 100 | ]; |
64 | if whitelist.iter().any(|p| path.ends_with(p)) { | 101 | if need_todo.iter().any(|p| path.ends_with(p)) { |
65 | return; | 102 | return; |
66 | } | 103 | } |
67 | if text.contains("TODO") || text.contains("TOOD") || text.contains("todo!") { | 104 | if text.contains("TODO") || text.contains("TOOD") || text.contains("todo!") { |
@@ -139,7 +176,7 @@ impl TidyDocs { | |||
139 | ) | 176 | ) |
140 | } | 177 | } |
141 | 178 | ||
142 | let whitelist = [ | 179 | let poorly_documented = [ |
143 | "ra_hir", | 180 | "ra_hir", |
144 | "ra_hir_expand", | 181 | "ra_hir_expand", |
145 | "ra_ide", | 182 | "ra_ide", |
@@ -153,9 +190,9 @@ impl TidyDocs { | |||
153 | ]; | 190 | ]; |
154 | 191 | ||
155 | let mut has_fixmes = | 192 | let mut has_fixmes = |
156 | whitelist.iter().map(|it| (*it, false)).collect::<HashMap<&str, bool>>(); | 193 | poorly_documented.iter().map(|it| (*it, false)).collect::<HashMap<&str, bool>>(); |
157 | 'outer: for path in self.contains_fixme { | 194 | 'outer: for path in self.contains_fixme { |
158 | for krate in whitelist.iter() { | 195 | for krate in poorly_documented.iter() { |
159 | if path.components().any(|it| it.as_os_str() == *krate) { | 196 | if path.components().any(|it| it.as_os_str() == *krate) { |
160 | has_fixmes.insert(krate, true); | 197 | has_fixmes.insert(krate, true); |
161 | continue 'outer; | 198 | continue 'outer; |
@@ -166,7 +203,7 @@ impl TidyDocs { | |||
166 | 203 | ||
167 | for (krate, has_fixme) in has_fixmes.iter() { | 204 | for (krate, has_fixme) in has_fixmes.iter() { |
168 | if !has_fixme { | 205 | if !has_fixme { |
169 | panic!("crate {} is fully documented, remove it from the white list", krate) | 206 | panic!("crate {} is fully documented :tada:, remove it from the list of poorly documented crates", krate) |
170 | } | 207 | } |
171 | } | 208 | } |
172 | } | 209 | } |