aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/syntax/fuzz/Cargo.toml4
-rw-r--r--xtask/src/lib.rs33
-rw-r--r--xtask/tests/tidy.rs27
3 files changed, 50 insertions, 14 deletions
diff --git a/crates/syntax/fuzz/Cargo.toml b/crates/syntax/fuzz/Cargo.toml
index 32c40d1b9..e22cd6b0c 100644
--- a/crates/syntax/fuzz/Cargo.toml
+++ b/crates/syntax/fuzz/Cargo.toml
@@ -10,8 +10,8 @@ edition = "2018"
10cargo-fuzz = true 10cargo-fuzz = true
11 11
12[dependencies] 12[dependencies]
13syntax = { path = ".." } 13syntax = { path = "..", version = "0.0.0" }
14text_edit = { path = "../../text_edit" } 14text_edit = { path = "../../text_edit", version = "0.0.0" }
15libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } 15libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }
16 16
17# Prevent this from interfering with workspaces 17# Prevent this from interfering with workspaces
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 16b06b853..b19985fb2 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -38,19 +38,13 @@ pub fn rust_files() -> impl Iterator<Item = PathBuf> {
38 rust_files_in(&project_root().join("crates")) 38 rust_files_in(&project_root().join("crates"))
39} 39}
40 40
41pub fn rust_files_in(path: &Path) -> impl Iterator<Item = PathBuf> { 41pub fn cargo_files() -> impl Iterator<Item = PathBuf> {
42 let iter = WalkDir::new(path); 42 files_in(&project_root(), "toml")
43 return iter 43 .filter(|path| path.file_name().map(|it| it == "Cargo.toml").unwrap_or(false))
44 .into_iter() 44}
45 .filter_entry(|e| !is_hidden(e))
46 .map(|e| e.unwrap())
47 .filter(|e| !e.file_type().is_dir())
48 .map(|e| e.into_path())
49 .filter(|path| path.extension().map(|it| it == "rs").unwrap_or(false));
50 45
51 fn is_hidden(entry: &DirEntry) -> bool { 46pub fn rust_files_in(path: &Path) -> impl Iterator<Item = PathBuf> {
52 entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false) 47 files_in(path, "rs")
53 }
54} 48}
55 49
56pub fn run_rustfmt(mode: Mode) -> Result<()> { 50pub fn run_rustfmt(mode: Mode) -> Result<()> {
@@ -120,3 +114,18 @@ fn date_iso() -> Result<String> {
120fn is_release_tag(tag: &str) -> bool { 114fn is_release_tag(tag: &str) -> bool {
121 tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) 115 tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit())
122} 116}
117
118fn files_in(path: &Path, ext: &'static str) -> impl Iterator<Item = PathBuf> {
119 let iter = WalkDir::new(path);
120 return iter
121 .into_iter()
122 .filter_entry(|e| !is_hidden(e))
123 .map(|e| e.unwrap())
124 .filter(|e| !e.file_type().is_dir())
125 .map(|e| e.into_path())
126 .filter(move |path| path.extension().map(|it| it == ext).unwrap_or(false));
127
128 fn is_hidden(entry: &DirEntry) -> bool {
129 entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false)
130 }
131}
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 9a6933b09..cb83e07fd 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -5,6 +5,7 @@ use std::{
5 5
6use xshell::{cmd, read_file}; 6use xshell::{cmd, read_file};
7use xtask::{ 7use xtask::{
8 cargo_files,
8 codegen::{self, Mode}, 9 codegen::{self, Mode},
9 project_root, run_rustfmt, rust_files, 10 project_root, run_rustfmt, rust_files,
10}; 11};
@@ -94,6 +95,32 @@ fn rust_files_are_tidy() {
94} 95}
95 96
96#[test] 97#[test]
98fn cargo_files_are_tidy() {
99 for cargo in cargo_files() {
100 let mut section = None;
101 for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() {
102 let text = text.trim();
103 if text.starts_with("[") {
104 section = Some(text);
105 continue;
106 }
107 if !section.map(|it| it.starts_with("[dependencies")).unwrap_or(false) {
108 continue;
109 }
110 let text: String = text.split_whitespace().collect();
111 if text.contains("path=") && !text.contains("version") {
112 panic!(
113 "\ncargo internal dependencies should have version.\n\
114 {}:{}\n",
115 cargo.display(),
116 line_no + 1
117 )
118 }
119 }
120 }
121}
122
123#[test]
97fn check_merge_commits() { 124fn check_merge_commits() {
98 let stdout = cmd!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19..") 125 let stdout = cmd!("git rev-list --merges --invert-grep --author 'bors\\[bot\\]' HEAD~19..")
99 .read() 126 .read()