]> git.proxmox.com Git - rustc.git/blob - src/tools/tidy/src/rustdoc_gui_tests.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / src / tools / tidy / src / rustdoc_gui_tests.rs
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 }