-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`
- Loading branch information
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters