aboutsummaryrefslogtreecommitdiff
path: root/xtask/tests
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/tests')
-rw-r--r--xtask/tests/tidy.rs36
1 files changed, 28 insertions, 8 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index b3bb9d543..d335adb72 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
@@ -48,14 +48,13 @@ fn smoke_test_docs_generation() {
48fn check_lsp_extensions_docs() { 48fn check_lsp_extensions_docs() {
49 let expected_hash = { 49 let expected_hash = {
50 let lsp_ext_rs = 50 let lsp_ext_rs =
51 fs2::read_to_string(project_root().join("crates/rust-analyzer/src/lsp_ext.rs")) 51 read_file(project_root().join("crates/rust-analyzer/src/lsp_ext.rs")).unwrap();
52 .unwrap();
53 stable_hash(lsp_ext_rs.as_str()) 52 stable_hash(lsp_ext_rs.as_str())
54 }; 53 };
55 54
56 let actual_hash = { 55 let actual_hash = {
57 let lsp_extensions_md = 56 let lsp_extensions_md =
58 fs2::read_to_string(project_root().join("docs/dev/lsp-extensions.md")).unwrap(); 57 read_file(project_root().join("docs/dev/lsp-extensions.md")).unwrap();
59 let text = lsp_extensions_md 58 let text = lsp_extensions_md
60 .lines() 59 .lines()
61 .find_map(|line| line.strip_prefix("lsp_ext.rs hash:")) 60 .find_map(|line| line.strip_prefix("lsp_ext.rs hash:"))
@@ -83,7 +82,7 @@ Please adjust docs/dev/lsp-extensions.md.
83fn rust_files_are_tidy() { 82fn rust_files_are_tidy() {
84 let mut tidy_docs = TidyDocs::default(); 83 let mut tidy_docs = TidyDocs::default();
85 for path in rust_files(&project_root().join("crates")) { 84 for path in rust_files(&project_root().join("crates")) {
86 let text = fs2::read_to_string(&path).unwrap(); 85 let text = read_file(&path).unwrap();
87 check_todo(&path, &text); 86 check_todo(&path, &text);
88 check_trailing_ws(&path, &text); 87 check_trailing_ws(&path, &text);
89 deny_clippy(&path, &text); 88 deny_clippy(&path, &text);
@@ -94,8 +93,10 @@ fn rust_files_are_tidy() {
94 93
95#[test] 94#[test]
96fn check_merge_commits() { 95fn check_merge_commits() {
97 let stdout = run!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19.."; echo = false) 96 let stdout =
98 .unwrap(); 97 dbg!(cmd!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19.."))
98 .read()
99 .unwrap();
99 if !stdout.is_empty() { 100 if !stdout.is_empty() {
100 panic!( 101 panic!(
101 " 102 "
@@ -168,7 +169,7 @@ Zlib OR Apache-2.0 OR MIT
168 .filter(|it| !it.is_empty()) 169 .filter(|it| !it.is_empty())
169 .collect::<Vec<_>>(); 170 .collect::<Vec<_>>();
170 171
171 let meta = run!("cargo metadata --format-version 1"; echo = false).unwrap(); 172 let meta = cmd!("cargo metadata --format-version 1").read().unwrap();
172 let mut licenses = meta 173 let mut licenses = meta
173 .split(|c| c == ',' || c == '{' || c == '}') 174 .split(|c| c == ',' || c == '{' || c == '}')
174 .filter(|it| it.contains(r#""license""#)) 175 .filter(|it| it.contains(r#""license""#))
@@ -177,6 +178,25 @@ Zlib OR Apache-2.0 OR MIT
177 .collect::<Vec<_>>(); 178 .collect::<Vec<_>>();
178 licenses.sort(); 179 licenses.sort();
179 licenses.dedup(); 180 licenses.dedup();
181 if licenses != expected {
182 let mut diff = String::new();
183
184 diff += &format!("New Licenses:\n");
185 for &l in licenses.iter() {
186 if !expected.contains(&l) {
187 diff += &format!(" {}\n", l)
188 }
189 }
190
191 diff += &format!("\nMissing Licenses:\n");
192 for &l in expected.iter() {
193 if !licenses.contains(&l) {
194 diff += &format!(" {}\n", l)
195 }
196 }
197
198 panic!("different set of licenses!\n{}", diff);
199 }
180 assert_eq!(licenses, expected); 200 assert_eq!(licenses, expected);
181} 201}
182 202