Skip to content

Commit 2ac7443

Browse files
Add tidy check to ensure that the tests present in src/test/ui/rustdoc are present in src/test/rustdoc-ui
1 parent 1f94abc commit 2ac7443

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/tools/tidy/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub mod errors;
4646
pub mod extdeps;
4747
pub mod features;
4848
pub mod pal;
49+
pub mod rustdoc_ui_test_parity;
4950
pub mod style;
5051
pub mod target_specific_tests;
5152
pub mod ui_tests;

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fn main() {
6464
// Checks over tests.
6565
check!(debug_artifacts, &src_path);
6666
check!(ui_tests, &src_path);
67+
check!(rustdoc_ui_test_parity, &src_path);
6768

6869
// Checks that only make sense for the compiler.
6970
check!(errors, &compiler_path);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//! Tidy check to ensure that `src/test/ui/rustdoc` tests are all present in `src/test/rustdoc-ui`.
2+
3+
use std::collections::HashSet;
4+
use std::path::Path;
5+
6+
pub fn check(path: &Path, bad: &mut bool) {
7+
let rustdoc_ui_folder = "src/test/rustdoc-ui";
8+
let ui_rustdoc_folder = "src/test/ui/rustdoc";
9+
let mut rustdoc_ui_tests = HashSet::new();
10+
super::walk_no_read(&path.join("test/rustdoc-ui"), &mut |_| false, &mut |entry| {
11+
let file_path = entry.path();
12+
if let Some(ext) = file_path.extension() {
13+
if ext == "rs" {
14+
let testname = file_path.file_name().unwrap().to_str().unwrap().to_owned();
15+
rustdoc_ui_tests.insert(testname);
16+
}
17+
}
18+
});
19+
super::walk_no_read(&path.join("test/ui/rustdoc"), &mut |_| false, &mut |entry| {
20+
let file_path = entry.path();
21+
if let Some(ext) = file_path.extension() {
22+
if ext == "rs" {
23+
let testname = file_path.file_name().unwrap().to_str().unwrap().to_owned();
24+
if !rustdoc_ui_tests.contains(&testname) {
25+
tidy_error!(
26+
bad,
27+
"{}",
28+
&format!(
29+
"`{}/{}` is missing from `{}`",
30+
ui_rustdoc_folder, testname, rustdoc_ui_folder,
31+
),
32+
);
33+
}
34+
}
35+
}
36+
});
37+
}

0 commit comments

Comments
 (0)