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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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)

0 commit comments

Comments
 (0)