Skip to content

Commit 7659ef4

Browse files
Use include command to reduce code duplication
1 parent 5958f5e commit 7659ef4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+112
-150
lines changed

tests/rustdoc-gui/anchors.goml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test is to ensure that the anchors (`§`) have the expected color and position.
2+
include: "utils.goml"
23

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

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

1614
assert-css: ("#toggle-all-docs", {"color": |main_color|})
1715
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})

tests/rustdoc-gui/code-color.goml

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// check that the rule isn't applied on other "<code>" elements.
33
//
44
// While we're at it, we also check it for the other themes.
5+
include: "utils.goml"
56
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
67
// If the text isn't displayed, the browser doesn't compute color style correctly...
78
show-text: true
@@ -10,10 +11,7 @@ define-function: (
1011
"check-colors",
1112
[theme, doc_code_color, doc_inline_code_color],
1213
block {
13-
// Set the theme.
14-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
15-
// We reload the page so the local storage settings are being used.
16-
reload:
14+
call-function: ("switch-theme", {"theme": |theme|})
1715
assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL)
1816
assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)
1917
},

tests/rustdoc-gui/codeblock-tooltip.goml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Checking the colors of the codeblocks tooltips.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
34
show-text: true
45

56
define-function: (
67
"check-colors",
78
[theme, background, color, border],
89
block {
9-
// Setting the theme.
10-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
11-
reload:
10+
call-function: ("switch-theme", {"theme": |theme|})
1211

1312
// compile_fail block
1413
assert-css: (

tests/rustdoc-gui/docblock-code-block-line-number.goml

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Checks that the setting "line numbers" is working as expected.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
34

45
// Otherwise, we can't check text color
@@ -13,14 +14,10 @@ define-function: (
1314
[theme, color],
1415
block {
1516
// We now set the setting to show the line numbers on code examples.
16-
set-local-storage: {
17-
"rustdoc-theme": |theme|,
18-
"rustdoc-use-system-theme": "false",
19-
"rustdoc-line-numbers": "true"
20-
}
21-
// We reload to make the line numbers appear and change theme.
22-
reload:
23-
// We wait for them to be added into the DOM by the JS...
17+
set-local-storage: {"rustdoc-line-numbers": "true"}
18+
// Page will be reloaded in "switch-theme".
19+
call-function: ("switch-theme", {"theme": |theme|})
20+
// We wait for the line numbers to be added into the DOM by the JS...
2421
wait-for: "pre.example-line-numbers"
2522
// If the test didn't fail, it means that it was found!
2623
assert-css: (

tests/rustdoc-gui/docblock-details.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This ensures that the `<details>`/`<summary>` elements are displayed as expected.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html"
34
show-text: true
4-
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
5-
reload:
5+
call-function: ("switch-theme", {"theme": "dark"})
66

77
// We first check that the headers in the `.top-doc` doc block still have their
88
// bottom border.

tests/rustdoc-gui/docblock-table.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test checks the appearance of the tables in the doc comments.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func"
34

45
compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"])
@@ -8,8 +9,7 @@ define-function: (
89
"check-colors",
910
[theme, border_color, zebra_stripe_color],
1011
block {
11-
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
12-
reload:
12+
call-function: ("switch-theme", {"theme": |theme|})
1313
assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", {
1414
"background-color": "rgba(0, 0, 0, 0)",
1515
})

tests/rustdoc-gui/headers-color.goml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// This test check for headings text and background colors for the different themes.
22

3+
include: "utils.goml"
4+
35
define-function: (
46
"check-colors",
57
[theme, color, code_header_color, focus_background_color, headings_color],
68
block {
79
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
810
// This is needed so that the text color is computed.
911
show-text: true
10-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
11-
reload:
12+
call-function: ("switch-theme", {"theme": |theme|})
1213
assert-css: (
1314
".impl",
1415
{"color": |color|, "background-color": "rgba(0, 0, 0, 0)"},

tests/rustdoc-gui/headings.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// 18px 1.125em
1212
// 16px 1rem
1313
// 14px 0.875rem
14+
include: "utils.goml"
1415
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
1516

1617
assert-css: (".main-heading h1", {"font-size": "24px"})
@@ -158,8 +159,8 @@ define-function: (
158159
"check-colors",
159160
[theme, heading_color, small_heading_color, heading_border_color],
160161
block {
161-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
162-
reload:
162+
call-function: ("switch-theme", {"theme": |theme|})
163+
163164
assert-css: (
164165
".top-doc .docblock h2",
165166
{"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
@@ -222,8 +223,7 @@ define-function: (
222223
"check-since-color",
223224
[theme],
224225
block {
225-
set-local-storage: {"rustdoc-theme": |theme|}
226-
reload:
226+
call-function: ("switch-theme", {"theme": |theme|})
227227
assert-css: (".since", {"color": "#808080"}, ALL)
228228
},
229229
)

tests/rustdoc-gui/help-page.goml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test ensures that opening the help page in its own tab works.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/help.html"
34
set-window-size: (1000, 1000) // Try desktop size first.
45
wait-for: "#help"
@@ -19,10 +20,7 @@ define-function: (
1920
"check-colors",
2021
[theme, color, background, box_shadow],
2122
block {
22-
// Setting the theme.
23-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
24-
// We reload the page so the local storage settings are being used.
25-
reload:
23+
call-function: ("switch-theme", {"theme": |theme|})
2624
assert-css: ("#help kbd", {
2725
"color": |color|,
2826
"background-color": |background|,

tests/rustdoc-gui/highlight-colors.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test checks the highlight colors in the source code pages.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
34
show-text: true
45

@@ -22,8 +23,7 @@ define-function: (
2223
doc_comment,
2324
],
2425
block {
25-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
26-
reload:
26+
call-function: ("switch-theme", {"theme": |theme|})
2727
assert-css: ("pre.rust .kw", {"color": |kw|}, ALL)
2828
assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL)
2929
assert-css: ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)

tests/rustdoc-gui/item-decl-colors.goml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// This test ensures that the color of the items in the type decl are working as expected.
22

3+
include: "utils.goml"
4+
35
// We need to disable this check because `trait.impl/test_docs/trait.TraitWithoutGenerics.js`
46
// doesn't exist.
57
fail-on-request-error: false
@@ -21,8 +23,8 @@ define-function: (
2123
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"
2224
show-text: true
2325

24-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
25-
reload:
26+
call-function: ("switch-theme", {"theme": |theme|})
27+
2628
assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL)
2729
assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL)
2830
// We need to add `code` here because otherwise it would select the parent too.

tests/rustdoc-gui/item-decl-comment-highlighting.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test checks that comments in item declarations are highlighted.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
34
show-text: true
45

@@ -7,8 +8,7 @@ define-function: (
78
[theme, url, comment_color],
89
block {
910
go-to: |url|
10-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
11-
reload:
11+
call-function: ("switch-theme", {"theme": |theme|})
1212
assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
1313
}
1414
)

tests/rustdoc-gui/jump-to-def-background.goml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// We check the background color on the jump to definition links in the src code page.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"
34

45
define-function: (
56
"check-background-color",
67
[theme, background_color],
78
block {
8-
// Set the theme.
9-
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }
10-
// We reload the page so the local storage settings are being used.
11-
reload:
9+
call-function: ("switch-theme", {"theme": |theme|})
1210
assert-css: (
1311
"body.src .example-wrap pre.rust a",
1412
{"background-color": |background_color|},

tests/rustdoc-gui/links-color.goml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test checks links colors.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
34

45
// This is needed so that the text color is computed.
@@ -9,11 +10,7 @@ define-function: (
910
[theme, mod, macro, struct, enum, trait, fn, type, union, keyword,
1011
sidebar, sidebar_current, sidebar_current_background],
1112
block {
12-
set-local-storage: {
13-
"rustdoc-theme": |theme|,
14-
"rustdoc-use-system-theme": "false",
15-
}
16-
reload:
13+
call-function: ("switch-theme", {"theme": |theme|})
1714
// Checking results colors.
1815
assert-css: (".item-table .mod", {"color": |mod|}, ALL)
1916
assert-css: (".item-table .macro", {"color": |macro|}, ALL)

tests/rustdoc-gui/notable-trait.goml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test checks the position of the `i` for the notable traits.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
34
show-text: true
45
// We start with a wide screen.
@@ -128,10 +129,7 @@ define-function: (
128129
// This is needed to ensure that the text color is computed.
129130
show-text: true
130131

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

136134
assert-css: (
137135
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",

tests/rustdoc-gui/pocket-menu.goml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test ensures that the "pocket menus" are working as expected.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
34
// First we check that the help menu doesn't exist yet.
45
assert-false: "#help-button .popover"
@@ -33,11 +34,7 @@ define-function: (
3334
"check-popover-colors",
3435
[theme, border_color],
3536
block {
36-
set-local-storage: {
37-
"rustdoc-theme": |theme|,
38-
"rustdoc-use-system-theme": "false",
39-
}
40-
reload:
37+
call-function: ("switch-theme", {"theme": |theme|})
4138

4239
click: "#help-button"
4340
assert-css: (

tests/rustdoc-gui/run-on-hover.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// Playground. That button is hidden until the user hovers over the code block.
33
// This test checks that it is hidden, and that it shows on hover. It also
44
// checks for its color.
5+
include: "utils.goml"
56
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
67
show-text: true
78

89
define-function: (
910
"check-run-button",
1011
[theme, color, background, hover_color, hover_background],
1112
block {
12-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
13-
reload:
13+
call-function: ("switch-theme", {"theme": |theme|})
1414
assert-css: (".test-arrow", {"visibility": "hidden"})
1515
move-cursor-to: ".example-wrap"
1616
assert-css: (".test-arrow", {

tests/rustdoc-gui/rust-logo.goml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This test ensures that the correct style is applied to the rust logo in the sidebar.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
34

45
define-function: (
@@ -8,14 +9,12 @@ define-function: (
89
// Going to the doc page.
910
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
1011
// Changing theme.
11-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
12-
reload:
12+
call-function: ("switch-theme", {"theme": |theme|})
1313
assert-css: (".rust-logo", {"filter": |filter|})
1414
// Now we check that the non-rust logos don't have a CSS filter set.
1515
go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html"
1616
// Changing theme on the new page (again...).
17-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
18-
reload:
17+
call-function: ("switch-theme", {"theme": |theme|})
1918
// Check there is no rust logo
2019
assert-false: ".rust-logo"
2120
// Check there is no filter.

tests/rustdoc-gui/scrape-examples-color.goml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Check that scrape example code blocks have the expected colors.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
34
show-text: true
45

@@ -7,8 +8,7 @@ define-function: (
78
[theme, highlight, highlight_focus, help_border, help_color, help_hover_border,
89
help_hover_color],
910
block {
10-
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
11-
reload:
11+
call-function: ("switch-theme", {"theme": |theme|})
1212
wait-for: ".more-examples-toggle"
1313
assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
1414
"background-color": |highlight|,
@@ -66,8 +66,7 @@ define-function: (
6666
"check-background",
6767
[theme, background_color_start, background_color_end],
6868
block {
69-
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
70-
reload:
69+
call-function: ("switch-theme", {"theme": |theme|})
7170
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
7271
"background-image": "linear-gradient(" + |background_color_start| + ", " +
7372
|background_color_end| + ")",

tests/rustdoc-gui/scrape-examples-toggle.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// This tests checks that the "scraped examples" toggle is working as expected.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
34

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

1313
// Clicking "More examples..." will open additional examples
1414
assert-attribute-false: (".more-examples-toggle", {"open": ""})

tests/rustdoc-gui/search-error.goml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
// Checks that the crate search filtering is handled correctly and changes the results.
2+
include: "utils.goml"
23
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds"
34
show-text: true
45

56
define-function: (
67
"check-colors",
78
[theme, error_background],
89
block {
9-
// Setting the theme.
10-
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
11-
// We reload the page so the local storage settings are being used.
12-
reload:
13-
10+
call-function: ("switch-theme", {"theme": |theme|})
1411
wait-for: "#search .error code"
1512
assert-css: ("#search .error code", {"background-color": |error_background|})
1613
}

0 commit comments

Comments
 (0)