aboutsummaryrefslogtreecommitdiff
path: root/xtask/tests/tidy.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/tests/tidy.rs')
-rw-r--r--xtask/tests/tidy.rs39
1 files changed, 30 insertions, 9 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index b3bb9d543..faaef2fd4 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -3,9 +3,9 @@ use std::{
3 path::{Path, PathBuf}, 3 path::{Path, PathBuf},
4}; 4};
5 5
6use xshell::{cmd, read_file};
6use xtask::{ 7use xtask::{
7 codegen::{self, Mode}, 8 codegen::{self, Mode},
8 not_bash::{fs2, run},
9 project_root, run_rustfmt, rust_files, 9 project_root, run_rustfmt, rust_files,
10}; 10};
11 11
@@ -42,20 +42,20 @@ fn smoke_test_docs_generation() {
42 // We don't commit docs to the repo, so we can just overwrite in tests. 42 // We don't commit docs to the repo, so we can just overwrite in tests.
43 codegen::generate_assists_docs(Mode::Overwrite).unwrap(); 43 codegen::generate_assists_docs(Mode::Overwrite).unwrap();
44 codegen::generate_feature_docs(Mode::Overwrite).unwrap(); 44 codegen::generate_feature_docs(Mode::Overwrite).unwrap();
45 codegen::generate_diagnostic_docs(Mode::Overwrite).unwrap();
45} 46}
46 47
47#[test] 48#[test]
48fn check_lsp_extensions_docs() { 49fn check_lsp_extensions_docs() {
49 let expected_hash = { 50 let expected_hash = {
50 let lsp_ext_rs = 51 let lsp_ext_rs =
51 fs2::read_to_string(project_root().join("crates/rust-analyzer/src/lsp_ext.rs")) 52 read_file(project_root().join("crates/rust-analyzer/src/lsp_ext.rs")).unwrap();
52 .unwrap();
53 stable_hash(lsp_ext_rs.as_str()) 53 stable_hash(lsp_ext_rs.as_str())
54 }; 54 };
55 55
56 let actual_hash = { 56 let actual_hash = {
57 let lsp_extensions_md = 57 let lsp_extensions_md =
58 fs2::read_to_string(project_root().join("docs/dev/lsp-extensions.md")).unwrap(); 58 read_file(project_root().join("docs/dev/lsp-extensions.md")).unwrap();
59 let text = lsp_extensions_md 59 let text = lsp_extensions_md
60 .lines() 60 .lines()
61 .find_map(|line| line.strip_prefix("lsp_ext.rs hash:")) 61 .find_map(|line| line.strip_prefix("lsp_ext.rs hash:"))
@@ -83,7 +83,7 @@ Please adjust docs/dev/lsp-extensions.md.
83fn rust_files_are_tidy() { 83fn rust_files_are_tidy() {
84 let mut tidy_docs = TidyDocs::default(); 84 let mut tidy_docs = TidyDocs::default();
85 for path in rust_files(&project_root().join("crates")) { 85 for path in rust_files(&project_root().join("crates")) {
86 let text = fs2::read_to_string(&path).unwrap(); 86 let text = read_file(&path).unwrap();
87 check_todo(&path, &text); 87 check_todo(&path, &text);
88 check_trailing_ws(&path, &text); 88 check_trailing_ws(&path, &text);
89 deny_clippy(&path, &text); 89 deny_clippy(&path, &text);
@@ -94,8 +94,10 @@ fn rust_files_are_tidy() {
94 94
95#[test] 95#[test]
96fn check_merge_commits() { 96fn check_merge_commits() {
97 let stdout = run!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19.."; echo = false) 97 let stdout =
98 .unwrap(); 98 dbg!(cmd!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19.."))
99 .read()
100 .unwrap();
99 if !stdout.is_empty() { 101 if !stdout.is_empty() {
100 panic!( 102 panic!(
101 " 103 "
@@ -168,7 +170,7 @@ Zlib OR Apache-2.0 OR MIT
168 .filter(|it| !it.is_empty()) 170 .filter(|it| !it.is_empty())
169 .collect::<Vec<_>>(); 171 .collect::<Vec<_>>();
170 172
171 let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap(); 173 let meta = cmd!("cargo metadata --format-version 1").read().unwrap();
172 let mut licenses = meta 174 let mut licenses = meta
173 .split(|c| c == ',' || c == '{' || c == '}') 175 .split(|c| c == ',' || c == '{' || c == '}')
174 .filter(|it| it.contains(r#""license""#)) 176 .filter(|it| it.contains(r#""license""#))
@@ -177,6 +179,25 @@ Zlib OR Apache-2.0 OR MIT
177 .collect::<Vec<_>>(); 179 .collect::<Vec<_>>();
178 licenses.sort(); 180 licenses.sort();
179 licenses.dedup(); 181 licenses.dedup();
182 if licenses != expected {
183 let mut diff = String::new();
184
185 diff += &format!("New Licenses:\n");
186 for &l in licenses.iter() {
187 if !expected.contains(&l) {
188 diff += &format!(" {}\n", l)
189 }
190 }
191
192 diff += &format!("\nMissing Licenses:\n");
193 for &l in expected.iter() {
194 if !licenses.contains(&l) {
195 diff += &format!(" {}\n", l)
196 }
197 }
198
199 panic!("different set of licenses!\n{}", diff);
200 }
180 assert_eq!(licenses, expected); 201 assert_eq!(licenses, expected);
181} 202}
182 203
@@ -193,7 +214,7 @@ fn check_todo(path: &Path, text: &str) {
193 // `ast::make`. 214 // `ast::make`.
194 "ast/make.rs", 215 "ast/make.rs",
195 // The documentation in string literals may contain anything for its own purposes 216 // The documentation in string literals may contain anything for its own purposes
196 "completion/generated_features.rs", 217 "completion/src/generated_features.rs",
197 ]; 218 ];
198 if need_todo.iter().any(|p| path.ends_with(p)) { 219 if need_todo.iter().any(|p| path.ends_with(p)) {
199 return; 220 return;