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.rs54
1 files changed, 46 insertions, 8 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 6bfa922e6..6abad189a 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -85,6 +85,7 @@ fn rust_files_are_tidy() {
85 for path in rust_files(&project_root().join("crates")) { 85 for path in rust_files(&project_root().join("crates")) {
86 let text = read_file(&path).unwrap(); 86 let text = read_file(&path).unwrap();
87 check_todo(&path, &text); 87 check_todo(&path, &text);
88 check_dbg(&path, &text);
88 check_trailing_ws(&path, &text); 89 check_trailing_ws(&path, &text);
89 deny_clippy(&path, &text); 90 deny_clippy(&path, &text);
90 tidy_docs.visit(&path, &text); 91 tidy_docs.visit(&path, &text);
@@ -94,10 +95,9 @@ fn rust_files_are_tidy() {
94 95
95#[test] 96#[test]
96fn check_merge_commits() { 97fn check_merge_commits() {
97 let stdout = 98 let stdout = cmd!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19..")
98 dbg!(cmd!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19..")) 99 .read()
99 .read() 100 .unwrap();
100 .unwrap();
101 if !stdout.is_empty() { 101 if !stdout.is_empty() {
102 panic!( 102 panic!(
103 " 103 "
@@ -107,8 +107,13 @@ When updating a pull-request, please rebase your feature branch
107on top of master by running `git rebase master`. If rebase fails, 107on top of master by running `git rebase master`. If rebase fails,
108you can re-apply your changes like this: 108you can re-apply your changes like this:
109 109
110 # Abort in-progress rebase, if any. 110 # Just look around to see the current state.
111 $ git status
112 $ git log
113
114 # Abort in-progress rebase and merges, if any.
111 $ git rebase --abort 115 $ git rebase --abort
116 $ git merge --abort
112 117
113 # Make the branch point to the latest commit from master, 118 # Make the branch point to the latest commit from master,
114 # while maintaining your local changes uncommited. 119 # while maintaining your local changes uncommited.
@@ -117,10 +122,17 @@ you can re-apply your changes like this:
117 # Commit all changes in a single batch. 122 # Commit all changes in a single batch.
118 $ git commit -am'My changes' 123 $ git commit -am'My changes'
119 124
125 # Verify that everything looks alright.
126 $ git status
127 $ git log
128
120 # Push the changes. We did a rebase, so we need `--force` option. 129 # Push the changes. We did a rebase, so we need `--force` option.
121 # `--force-with-lease` is a more safe (Rusty) version of `--force`. 130 # `--force-with-lease` is a more safe (Rusty) version of `--force`.
122 $ git push --force-with-lease 131 $ git push --force-with-lease
123 132
133 # Verify that both local and remote branch point to the same commit.
134 $ git log
135
124And don't fear to mess something up during a rebase -- you can 136And don't fear to mess something up during a rebase -- you can
125always restore the previous state using `git ref-log`: 137always restore the previous state using `git ref-log`:
126 138
@@ -139,7 +151,7 @@ fn deny_clippy(path: &PathBuf, text: &String) {
139 return; 151 return;
140 } 152 }
141 153
142 if text.contains("[\u{61}llow(clippy") { 154 if text.contains("\u{61}llow(clippy") {
143 panic!( 155 panic!(
144 "\n\nallowing lints is forbidden: {}. 156 "\n\nallowing lints is forbidden: {}.
145rust-analyzer intentionally doesn't check clippy on CI. 157rust-analyzer intentionally doesn't check clippy on CI.
@@ -212,7 +224,7 @@ Zlib OR Apache-2.0 OR MIT
212fn check_todo(path: &Path, text: &str) { 224fn check_todo(path: &Path, text: &str) {
213 let need_todo = &[ 225 let need_todo = &[
214 // This file itself obviously needs to use todo (<- like this!). 226 // This file itself obviously needs to use todo (<- like this!).
215 "tests/cli.rs", 227 "tests/tidy.rs",
216 // Some of our assists generate `todo!()`. 228 // Some of our assists generate `todo!()`.
217 "handlers/add_turbo_fish.rs", 229 "handlers/add_turbo_fish.rs",
218 "handlers/generate_function.rs", 230 "handlers/generate_function.rs",
@@ -240,6 +252,32 @@ fn check_todo(path: &Path, text: &str) {
240 } 252 }
241} 253}
242 254
255fn check_dbg(path: &Path, text: &str) {
256 let need_dbg = &[
257 // This file itself obviously needs to use dbg.
258 "tests/tidy.rs",
259 // Assists to remove `dbg!()`
260 "handlers/remove_dbg.rs",
261 // We have .dbg postfix
262 "completion/src/completions/postfix.rs",
263 // The documentation in string literals may contain anything for its own purposes
264 "completion/src/lib.rs",
265 "completion/src/generated_lint_completions.rs",
266 // test for doc test for remove_dbg
267 "src/tests/generated.rs",
268 ];
269 if need_dbg.iter().any(|p| path.ends_with(p)) {
270 return;
271 }
272 if text.contains("dbg!") {
273 panic!(
274 "\ndbg! macros should not be committed to the master branch,\n\
275 {}\n",
276 path.display(),
277 )
278 }
279}
280
243fn check_trailing_ws(path: &Path, text: &str) { 281fn check_trailing_ws(path: &Path, text: &str) {
244 if is_exclude_dir(path, &["test_data"]) { 282 if is_exclude_dir(path, &["test_data"]) {
245 return; 283 return;
@@ -286,7 +324,7 @@ impl TidyDocs {
286 } 324 }
287 325
288 fn is_exclude_file(d: &Path) -> bool { 326 fn is_exclude_file(d: &Path) -> bool {
289 let file_names = ["tests.rs"]; 327 let file_names = ["tests.rs", "famous_defs_fixture.rs"];
290 328
291 d.file_name() 329 d.file_name()
292 .unwrap_or_default() 330 .unwrap_or_default()