Skip to content

Commit 72180b3

Browse files
authored
Rollup merge of #106888 - GuillaumeGomez:tidy-gui-test, r=notriddle
Add tidy check to ensure that rustdoc GUI tests start with a small description The first commit comes from #106865 to prevent CI to fail. This PR adds a tidy check to enforce having a small description at the top of the GUI test. Although the format is made to be as easy as possible to read, it's not always obvious what a test is actually checking. I think enforcing this will make it easier for us to come back on these tests if needed. r? `@notriddle`
2 parents ae4d89d + 5376670 commit 72180b3

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub mod features;
6262
pub mod mir_opt_tests;
6363
pub mod pal;
6464
pub mod primitive_docs;
65+
pub mod rustdoc_gui_tests;
6566
pub mod style;
6667
pub mod target_specific_tests;
6768
pub mod tests_placement;

src/tools/tidy/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ fn main() {
8080
check!(debug_artifacts, &tests_path);
8181
check!(ui_tests, &tests_path);
8282
check!(mir_opt_tests, &tests_path, bless);
83+
check!(rustdoc_gui_tests, &tests_path);
8384

8485
// Checks that only make sense for the compiler.
8586
check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], verbose);
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//! Tidy check to ensure that rustdoc GUI tests start with a small description.
2+
3+
use std::path::Path;
4+
5+
pub fn check(path: &Path, bad: &mut bool) {
6+
crate::walk::walk(
7+
&path.join("rustdoc-gui"),
8+
&mut |p| {
9+
// If there is no extension, it's very likely a folder and we want to go into it.
10+
p.extension().map(|e| e != "goml").unwrap_or(false)
11+
},
12+
&mut |entry, content| {
13+
for line in content.lines() {
14+
if !line.starts_with("// ") {
15+
tidy_error!(
16+
bad,
17+
"{}: rustdoc-gui tests must start with a small description",
18+
entry.path().display(),
19+
);
20+
return;
21+
} else if line.starts_with("// ") {
22+
let parts = line[2..].trim();
23+
// We ignore tidy comments.
24+
if parts.starts_with("// tidy-") {
25+
continue;
26+
}
27+
// All good!
28+
return;
29+
}
30+
}
31+
},
32+
);
33+
}

tests/rustdoc-gui/basic-code.goml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Small test to ensure the "src-line-numbers" element is only present once on
2+
// the page.
13
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
24
click: ".srclink"
35
wait-for: ".src-line-numbers"

0 commit comments

Comments
 (0)