From ecfbe2ecd455589bfc8815312a1620fea581a585 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 2 Sep 2023 22:58:12 -0700 Subject: [PATCH 1/2] Detect duplicate entries in exclusion lists --- tests/repo/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index 980a85470e..4094337fec 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -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: Trait` @@ -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); } From f3727bf1b7c9aa18f3af1dc6c32cbf95aa5761d2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 2 Sep 2023 23:03:02 -0700 Subject: [PATCH 2/2] Detect duplication between excluded files and dirs --- tests/repo/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/repo/mod.rs b/tests/repo/mod.rs index 4094337fec..bbf418f6b1 100644 --- a/tests/repo/mod.rs +++ b/tests/repo/mod.rs @@ -295,6 +295,11 @@ pub fn clone_rust() { if !exclude_files_set.insert(exclude) { panic!("duplicate path in EXCLUDE_FILES: {}", exclude); } + for dir in EXCLUDE_DIRS { + if Path::new(exclude).starts_with(dir) { + panic!("excluded file {} is inside an excluded dir", exclude); + } + } if !test_src.join(exclude).is_file() { missing += "\ntests/rust/"; missing += exclude;