Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use include command to reduce code duplication #123515

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tests/rustdoc-gui/anchors.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test is to ensure that the anchors (`§`) have the expected color and position.
include: "utils.goml"

define-function: (
"check-colors",
Expand All @@ -8,10 +9,7 @@ define-function: (
// This is needed to ensure that the text color is computed.
show-text: true

// Setting the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
call-function: ("switch-theme", {"theme": |theme|})

assert-css: ("#toggle-all-docs", {"color": |main_color|})
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
Expand Down
6 changes: 2 additions & 4 deletions tests/rustdoc-gui/code-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// check that the rule isn't applied on other "<code>" elements.
//
// While we're at it, we also check it for the other themes.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
// If the text isn't displayed, the browser doesn't compute color style correctly...
show-text: true
Expand All @@ -10,10 +11,7 @@ define-function: (
"check-colors",
[theme, doc_code_color, doc_inline_code_color],
block {
// Set the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL)
assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)
},
Expand Down
5 changes: 2 additions & 3 deletions tests/rustdoc-gui/codeblock-tooltip.goml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Checking the colors of the codeblocks tooltips.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
show-text: true

define-function: (
"check-colors",
[theme, background, color, border],
block {
// Setting the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})

// compile_fail block
assert-css: (
Expand Down
13 changes: 5 additions & 8 deletions tests/rustdoc-gui/docblock-code-block-line-number.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Checks that the setting "line numbers" is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"

// Otherwise, we can't check text color
Expand All @@ -13,14 +14,10 @@ define-function: (
[theme, color],
block {
// We now set the setting to show the line numbers on code examples.
set-local-storage: {
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
"rustdoc-line-numbers": "true"
}
// We reload to make the line numbers appear and change theme.
reload:
// We wait for them to be added into the DOM by the JS...
set-local-storage: {"rustdoc-line-numbers": "true"}
// Page will be reloaded in "switch-theme".
call-function: ("switch-theme", {"theme": |theme|})
// We wait for the line numbers to be added into the DOM by the JS...
wait-for: "pre.example-line-numbers"
// If the test didn't fail, it means that it was found!
assert-css: (
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/docblock-details.goml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// This ensures that the `<details>`/`<summary>` elements are displayed as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html"
show-text: true
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": "dark"})

// We first check that the headers in the `.top-doc` doc block still have their
// bottom border.
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/docblock-table.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test checks the appearance of the tables in the doc comments.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func"

compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"])
Expand All @@ -8,8 +9,7 @@ define-function: (
"check-colors",
[theme, border_color, zebra_stripe_color],
block {
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", {
"background-color": "rgba(0, 0, 0, 0)",
})
Expand Down
5 changes: 3 additions & 2 deletions tests/rustdoc-gui/headers-color.goml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// This test check for headings text and background colors for the different themes.

include: "utils.goml"

define-function: (
"check-colors",
[theme, color, code_header_color, focus_background_color, headings_color],
block {
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
// This is needed so that the text color is computed.
show-text: true
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (
".impl",
{"color": |color|, "background-color": "rgba(0, 0, 0, 0)"},
Expand Down
8 changes: 4 additions & 4 deletions tests/rustdoc-gui/headings.goml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 18px 1.125em
// 16px 1rem
// 14px 0.875rem
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"

assert-css: (".main-heading h1", {"font-size": "24px"})
Expand Down Expand Up @@ -158,8 +159,8 @@ define-function: (
"check-colors",
[theme, heading_color, small_heading_color, heading_border_color],
block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})

assert-css: (
".top-doc .docblock h2",
{"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
Expand Down Expand Up @@ -222,8 +223,7 @@ define-function: (
"check-since-color",
[theme],
block {
set-local-storage: {"rustdoc-theme": |theme|}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".since", {"color": "#808080"}, ALL)
},
)
Expand Down
6 changes: 2 additions & 4 deletions tests/rustdoc-gui/help-page.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test ensures that opening the help page in its own tab works.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/help.html"
set-window-size: (1000, 1000) // Try desktop size first.
wait-for: "#help"
Expand All @@ -19,10 +20,7 @@ define-function: (
"check-colors",
[theme, color, background, box_shadow],
block {
// Setting the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: ("#help kbd", {
"color": |color|,
"background-color": |background|,
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/highlight-colors.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test checks the highlight colors in the source code pages.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
show-text: true

Expand All @@ -22,8 +23,7 @@ define-function: (
doc_comment,
],
block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: ("pre.rust .kw", {"color": |kw|}, ALL)
assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL)
assert-css: ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)
Expand Down
6 changes: 4 additions & 2 deletions tests/rustdoc-gui/item-decl-colors.goml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// This test ensures that the color of the items in the type decl are working as expected.

include: "utils.goml"

// We need to disable this check because `trait.impl/test_docs/trait.TraitWithoutGenerics.js`
// doesn't exist.
fail-on-request-error: false
Expand All @@ -21,8 +23,8 @@ define-function: (
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"
show-text: true

set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})

assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL)
assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL)
// We need to add `code` here because otherwise it would select the parent too.
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/item-decl-comment-highlighting.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test checks that comments in item declarations are highlighted.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
show-text: true

Expand All @@ -7,8 +8,7 @@ define-function: (
[theme, url, comment_color],
block {
go-to: |url|
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
}
)
Expand Down
6 changes: 2 additions & 4 deletions tests/rustdoc-gui/jump-to-def-background.goml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// We check the background color on the jump to definition links in the src code page.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"

define-function: (
"check-background-color",
[theme, background_color],
block {
// Set the theme.
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }
// We reload the page so the local storage settings are being used.
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (
"body.src .example-wrap pre.rust a",
{"background-color": |background_color|},
Expand Down
7 changes: 2 additions & 5 deletions tests/rustdoc-gui/links-color.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test checks links colors.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"

// This is needed so that the text color is computed.
Expand All @@ -9,11 +10,7 @@ define-function: (
[theme, mod, macro, struct, enum, trait, fn, type, union, keyword,
sidebar, sidebar_current, sidebar_current_background],
block {
set-local-storage: {
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
call-function: ("switch-theme", {"theme": |theme|})
// Checking results colors.
assert-css: (".item-table .mod", {"color": |mod|}, ALL)
assert-css: (".item-table .macro", {"color": |macro|}, ALL)
Expand Down
6 changes: 2 additions & 4 deletions tests/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test checks the position of the `i` for the notable traits.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
show-text: true
// We start with a wide screen.
Expand Down Expand Up @@ -128,10 +129,7 @@ define-function: (
// This is needed to ensure that the text color is computed.
show-text: true

// Setting the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
call-function: ("switch-theme", {"theme": |theme|})

assert-css: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
Expand Down
7 changes: 2 additions & 5 deletions tests/rustdoc-gui/pocket-menu.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test ensures that the "pocket menus" are working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
// First we check that the help menu doesn't exist yet.
assert-false: "#help-button .popover"
Expand Down Expand Up @@ -33,11 +34,7 @@ define-function: (
"check-popover-colors",
[theme, border_color],
block {
set-local-storage: {
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
}
reload:
call-function: ("switch-theme", {"theme": |theme|})

click: "#help-button"
assert-css: (
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/run-on-hover.goml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Playground. That button is hidden until the user hovers over the code block.
// This test checks that it is hidden, and that it shows on hover. It also
// checks for its color.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
show-text: true

define-function: (
"check-run-button",
[theme, color, background, hover_color, hover_background],
block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".test-arrow", {"visibility": "hidden"})
move-cursor-to: ".example-wrap"
assert-css: (".test-arrow", {
Expand Down
7 changes: 3 additions & 4 deletions tests/rustdoc-gui/rust-logo.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test ensures that the correct style is applied to the rust logo in the sidebar.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"

define-function: (
Expand All @@ -8,14 +9,12 @@ define-function: (
// Going to the doc page.
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
// Changing theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".rust-logo", {"filter": |filter|})
// Now we check that the non-rust logos don't have a CSS filter set.
go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html"
// Changing theme on the new page (again...).
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})
// Check there is no rust logo
assert-false: ".rust-logo"
// Check there is no filter.
Expand Down
7 changes: 3 additions & 4 deletions tests/rustdoc-gui/scrape-examples-color.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Check that scrape example code blocks have the expected colors.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
show-text: true

Expand All @@ -7,8 +8,7 @@ define-function: (
[theme, highlight, highlight_focus, help_border, help_color, help_hover_border,
help_hover_color],
block {
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
reload:
call-function: ("switch-theme", {"theme": |theme|})
wait-for: ".more-examples-toggle"
assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
"background-color": |highlight|,
Expand Down Expand Up @@ -66,8 +66,7 @@ define-function: (
"check-background",
[theme, background_color_start, background_color_end],
block {
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
reload:
call-function: ("switch-theme", {"theme": |theme|})
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
"background-image": "linear-gradient(" + |background_color_start| + ", " +
|background_color_end| + ")",
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc-gui/scrape-examples-toggle.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This tests checks that the "scraped examples" toggle is working as expected.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"

// Checking the color of the toggle line.
Expand All @@ -7,8 +8,7 @@ define-function: (
"check-color",
[theme, toggle_line_color, toggle_line_hover_color],
block {
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
call-function: ("switch-theme", {"theme": |theme|})

// Clicking "More examples..." will open additional examples
assert-attribute-false: (".more-examples-toggle", {"open": ""})
Expand Down
7 changes: 2 additions & 5 deletions tests/rustdoc-gui/search-error.goml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// Checks that the crate search filtering is handled correctly and changes the results.
include: "utils.goml"
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds"
show-text: true

define-function: (
"check-colors",
[theme, error_background],
block {
// Setting the theme.
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:

call-function: ("switch-theme", {"theme": |theme|})
wait-for: "#search .error code"
assert-css: ("#search .error code", {"background-color": |error_background|})
}
Expand Down
Loading
Loading