aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-10-14 12:30:06 +0100
committerAleksey Kladov <[email protected]>2020-10-14 12:30:06 +0100
commitd852189e56056c1c1742ad56a09c4a3e4a75b170 (patch)
treee247fd2e0bc8246bb46342f523dce649ff178223 /xtask
parentb62f48f535039e123b46f2d8b3e9d403cbfe1967 (diff)
Add reminder to update lsp-extensions.md
Diffstat (limited to 'xtask')
-rw-r--r--xtask/tests/tidy.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 0c233f87d..b3bb9d543 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -45,6 +45,41 @@ fn smoke_test_docs_generation() {
45} 45}
46 46
47#[test] 47#[test]
48fn check_lsp_extensions_docs() {
49 let expected_hash = {
50 let lsp_ext_rs =
51 fs2::read_to_string(project_root().join("crates/rust-analyzer/src/lsp_ext.rs"))
52 .unwrap();
53 stable_hash(lsp_ext_rs.as_str())
54 };
55
56 let actual_hash = {
57 let lsp_extensions_md =
58 fs2::read_to_string(project_root().join("docs/dev/lsp-extensions.md")).unwrap();
59 let text = lsp_extensions_md
60 .lines()
61 .find_map(|line| line.strip_prefix("lsp_ext.rs hash:"))
62 .unwrap()
63 .trim();
64 u64::from_str_radix(text, 16).unwrap()
65 };
66
67 if actual_hash != expected_hash {
68 panic!(
69 "
70lsp_ext.rs was changed without touching lsp-extensions.md.
71
72Expected hash: {:x}
73Actual hash: {:x}
74
75Please adjust docs/dev/lsp-extensions.md.
76",
77 expected_hash, actual_hash
78 )
79 }
80}
81
82#[test]
48fn rust_files_are_tidy() { 83fn rust_files_are_tidy() {
49 let mut tidy_docs = TidyDocs::default(); 84 let mut tidy_docs = TidyDocs::default();
50 for path in rust_files(&project_root().join("crates")) { 85 for path in rust_files(&project_root().join("crates")) {
@@ -280,3 +315,13 @@ fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool {
280 .filter_map(|it| it.as_os_str().to_str()) 315 .filter_map(|it| it.as_os_str().to_str())
281 .any(|it| dirs_to_exclude.contains(&it)) 316 .any(|it| dirs_to_exclude.contains(&it))
282} 317}
318
319#[allow(deprecated)]
320fn stable_hash(text: &str) -> u64 {
321 use std::hash::{Hash, Hasher, SipHasher};
322
323 let text = text.replace('\r', "");
324 let mut hasher = SipHasher::default();
325 text.hash(&mut hasher);
326 hasher.finish()
327}