Skip to content

Commit

Permalink
Rollup merge of #106602 - GuillaumeGomez:tidy-goml-scripts, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

Add goml scripts to tidy checks

r? ``@notriddle``
  • Loading branch information
compiler-errors committed Jan 9, 2023
2 parents 29420a8 + 31b39be commit bb6a88a
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/escape-key.goml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
write: (".search-input", "test")
// To be SURE that the search will be run.
press-key: 'Enter'
wait-for: "#search h1" // The search element is empty before the first search
wait-for: "#search h1" // The search element is empty before the first search
// Check that the currently displayed element is search.
wait-for: "#alternative-display #search"
assert-attribute: ("#main-content", {"class": "content hidden"})
Expand Down
6 changes: 3 additions & 3 deletions src/test/rustdoc-gui/impl-doc.goml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ goto: "file://" + |DOC_PATH| + "/test_docs/struct.TypeWithImplDoc.html"

// The text is about 24px tall, so if there's a margin, then their position will be >24px apart
compare-elements-position-near-false: (
"#implementations-list > .implementors-toggle > .docblock > p",
"#implementations-list > .implementors-toggle > .impl-items",
{"y": 24}
"#implementations-list > .implementors-toggle > .docblock > p",
"#implementations-list > .implementors-toggle > .impl-items",
{"y": 24}
)
6 changes: 5 additions & 1 deletion src/test/rustdoc-gui/mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since
goto: "file://" + |DOC_PATH| + "/settings.html"
size: (400, 600)
// Ignored for now https://github.com/rust-lang/rust/issues/93784.
// compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16})
// compare-elements-position-near-false: (
// "#preferred-light-theme .setting-name",
// "#preferred-light-theme .choice",
// {"y": 16},
// )
21 changes: 18 additions & 3 deletions src/test/rustdoc-gui/rust-logo.goml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,28 @@ define-function: (

call-function: (
"check-logo",
("ayu", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"),
{
"theme": "ayu",
"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) " +
"drop-shadow(rgb(255, 255, 255) 0px 1px 0px) " +
"drop-shadow(rgb(255, 255, 255) -1px 0px 0px) " +
"drop-shadow(rgb(255, 255, 255) 0px -1px 0px)",
},
)
call-function: (
"check-logo",
("dark", "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px 1px 0px) drop-shadow(rgb(255, 255, 255) -1px 0px 0px) drop-shadow(rgb(255, 255, 255) 0px -1px 0px)"),
{
"theme": "dark",
"filter": "drop-shadow(rgb(255, 255, 255) 1px 0px 0px) " +
"drop-shadow(rgb(255, 255, 255) 0px 1px 0px) " +
"drop-shadow(rgb(255, 255, 255) -1px 0px 0px) " +
"drop-shadow(rgb(255, 255, 255) 0px -1px 0px)",
},
)
call-function: (
"check-logo",
("light", "none"),
{
"theme": "light",
"filter": "none",
},
)
10 changes: 5 additions & 5 deletions src/test/rustdoc-gui/scrape-examples-button-focus.goml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ store-property: (initialScrollTop, ".scraped-example-list > .scraped-example pre
focus: ".scraped-example-list > .scraped-example .next"
press-key: "Enter"
assert-property-false: (".scraped-example-list > .scraped-example pre", {
"scrollTop": |initialScrollTop|
"scrollTop": |initialScrollTop|
})
focus: ".scraped-example-list > .scraped-example .prev"
press-key: "Enter"
assert-property: (".scraped-example-list > .scraped-example pre", {
"scrollTop": |initialScrollTop|
"scrollTop": |initialScrollTop|
})

// The expand button increases the scrollHeight of the minimized code viewport
store-property: (smallOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
assert-property-false: (".scraped-example-list > .scraped-example pre", {
"scrollHeight": |smallOffsetHeight|
"scrollHeight": |smallOffsetHeight|
})
focus: ".scraped-example-list > .scraped-example .expand"
press-key: "Enter"
assert-property-false: (".scraped-example-list > .scraped-example pre", {
"offsetHeight": |smallOffsetHeight|
"offsetHeight": |smallOffsetHeight|
})
store-property: (fullOffsetHeight, ".scraped-example-list > .scraped-example pre", "offsetHeight")
assert-property: (".scraped-example-list > .scraped-example pre", {
"scrollHeight": |fullOffsetHeight|
"scrollHeight": |fullOffsetHeight|
})
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/sidebar.goml
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ assert-text: ("#toggle-all-docs", "[+]")
assert-property: (".sidebar", {"clientWidth": "200"})
click: "#toggle-all-docs"
assert-text: ("#toggle-all-docs", "[−]")
assert-property: (".sidebar", {"clientWidth": "200"})
assert-property: (".sidebar", {"clientWidth": "200"})
1 change: 1 addition & 0 deletions src/test/rustdoc-gui/type-declation-overflow.goml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-tidy-linelength
// This test ensures that the items declaration content overflow is handled inside the <pre> directly.

// We need to disable this check because
Expand Down
13 changes: 11 additions & 2 deletions src/tools/tidy/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use std::path::Path;
/// displayed on the console with --example.
const ERROR_CODE_COLS: usize = 80;
const COLS: usize = 100;
const GOML_COLS: usize = 120;

const LINES: usize = 3000;

Expand Down Expand Up @@ -230,7 +231,8 @@ pub fn check(path: &Path, bad: &mut bool) {
walk(path, &mut skip, &mut |entry, contents| {
let file = entry.path();
let filename = file.file_name().unwrap().to_string_lossy();
let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css", ".ftl"];
let extensions =
[".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css", ".ftl", ".goml"];
if extensions.iter().all(|e| !filename.ends_with(e)) || filename.starts_with(".#") {
return;
}
Expand All @@ -255,8 +257,15 @@ pub fn check(path: &Path, bad: &mut bool) {

let extension = file.extension().unwrap().to_string_lossy();
let is_error_code = extension == "md" && is_in(file, "src", "error_codes");
let is_goml_code = extension == "goml";

let max_columns = if is_error_code { ERROR_CODE_COLS } else { COLS };
let max_columns = if is_error_code {
ERROR_CODE_COLS
} else if is_goml_code {
GOML_COLS
} else {
COLS
};

let can_contain = contents.contains("// ignore-tidy-")
|| contents.contains("# ignore-tidy-")
Expand Down

0 comments on commit bb6a88a

Please sign in to comment.