diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-01-14 22:17:06 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-01-15 12:58:04 +0100 |
| commit | 98cfa68f16cb07a3c4bc18daeb071c53904a487f (patch) | |
| tree | d276ba79c6c1cddd895c37f48f88d688cfb3af74 | |
| parent | de34489a019b8e5319c09504ca158022df188d49 (diff) | |
| download | rust-98cfa68f16cb07a3c4bc18daeb071c53904a487f.tar.gz rust-98cfa68f16cb07a3c4bc18daeb071c53904a487f.zip | |
Add tidy check to ensure that rustdoc GUI tests start with a small description
| -rw-r--r-- | src/tools/tidy/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/tools/tidy/src/main.rs | 1 | ||||
| -rw-r--r-- | src/tools/tidy/src/rustdoc_gui_tests.rs | 33 |
3 files changed, 35 insertions, 0 deletions
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 40375f1306d..97e56720b98 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -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; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index ea2886a3c2f..0b9a1b37e94 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -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); diff --git a/src/tools/tidy/src/rustdoc_gui_tests.rs b/src/tools/tidy/src/rustdoc_gui_tests.rs new file mode 100644 index 00000000000..feb513df34b --- /dev/null +++ b/src/tools/tidy/src/rustdoc_gui_tests.rs @@ -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; + } + } + }, + ); +} |
