Skip to content

Commit

Permalink
Detect duplicate entries in exclusion lists
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 3, 2023
1 parent cd479c0 commit ecfbe2e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ static EXCLUDE_FILES: &[&str] = &[
// https://github.com/rust-lang/rust/issues/113333
"src/tools/clippy/tests/ui/needless_raw_string_hashes.rs",
"src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0085_expr_literals.rs",
"src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0085_expr_literals.rs",
"tests/ui/explicit-tail-calls/return-lifetime-sub.rs",

// TODO: non-lifetime binders: `where for<'a, T> &'a Struct<T>: Trait`
Expand Down Expand Up @@ -287,21 +286,33 @@ pub fn clone_rust() {
if needs_clone {
download_and_unpack().unwrap();
}

let mut missing = String::new();
let test_src = Path::new("tests/rust");

let mut exclude_files_set = BTreeSet::new();
for exclude in EXCLUDE_FILES {
if !exclude_files_set.insert(exclude) {
panic!("duplicate path in EXCLUDE_FILES: {}", exclude);
}
if !test_src.join(exclude).is_file() {
missing += "\ntests/rust/";
missing += exclude;
}
}

let mut exclude_dirs_set = BTreeSet::new();
for exclude in EXCLUDE_DIRS {
if !exclude_dirs_set.insert(exclude) {
panic!("duplicate path in EXCLUDE_DIRS: {}", exclude);
}
if !test_src.join(exclude).is_dir() {
missing += "\ntests/rust/";
missing += exclude;
missing += "/";
}
}

if !missing.is_empty() {
panic!("excluded test file does not exist:{}\n", missing);
}
Expand Down

0 comments on commit ecfbe2e

Please sign in to comment.