Skip to content

Add tidy check to ensure that rustdoc GUI tests start with a small description #106888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tools/tidy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub mod features;
pub mod mir_opt_tests;
pub mod pal;
pub mod primitive_docs;
pub mod rustdoc_gui_tests;
pub mod style;
pub mod target_specific_tests;
pub mod tests_placement;
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fn main() {
check!(debug_artifacts, &tests_path);
check!(ui_tests, &tests_path);
check!(mir_opt_tests, &tests_path, bless);
check!(rustdoc_gui_tests, &tests_path);

// Checks that only make sense for the compiler.
check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], verbose);
Expand Down
33 changes: 33 additions & 0 deletions src/tools/tidy/src/rustdoc_gui_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//! Tidy check to ensure that rustdoc GUI tests start with a small description.

use std::path::Path;

pub fn check(path: &Path, bad: &mut bool) {
crate::walk::walk(
&path.join("rustdoc-gui"),
&mut |p| {
// If there is no extension, it's very likely a folder and we want to go into it.
p.extension().map(|e| e != "goml").unwrap_or(false)
},
&mut |entry, content| {
for line in content.lines() {
if !line.starts_with("// ") {
tidy_error!(
bad,
"{}: rustdoc-gui tests must start with a small description",
entry.path().display(),
);
return;
} else if line.starts_with("// ") {
let parts = line[2..].trim();
// We ignore tidy comments.
if parts.starts_with("// tidy-") {
continue;
}
// All good!
return;
}
}
},
);
}
2 changes: 2 additions & 0 deletions tests/rustdoc-gui/basic-code.goml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Small test to ensure the "src-line-numbers" element is only present once on
// the page.
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink"
wait-for: ".src-line-numbers"
Expand Down