tidy/
rustdoc_gui_tests.rs

1//! Tidy check to ensure that rustdoc GUI tests start with a small description.
2
3use std::path::Path;
4
5use crate::diagnostics::{CheckId, DiagCtx};
6
7pub fn check(path: &Path, diag_ctx: DiagCtx) {
8    let mut check = diag_ctx.start_check(CheckId::new("rustdoc_gui_tests").path(path));
9
10    crate::walk::walk(
11        &path.join("rustdoc-gui"),
12        |p, is_dir| !is_dir && p.extension().is_none_or(|e| e != "goml"),
13        &mut |entry, content| {
14            for line in content.lines() {
15                if !line.starts_with("// ") {
16                    check.error(format!(
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}