Skip to content

Commit 3f4013d

Browse files
authored
Rollup merge of #91834 - GuillaumeGomez:improve-gui-test-readability, r=jsha
Update browser-ui-test version and improve rustdoc-gui tests readability Since the `0.5.1`, we can use trailing commas. I also used the opportunity to clean up the existing tests. r? `@notriddle`
2 parents 91a0600 + 6325086 commit 3f4013d

12 files changed

+279
-67
lines changed

src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
7272
# https://github.com/puppeteer/puppeteer/issues/375
7373
#
7474
# We also specify the version in case we need to update it to go around cache limitations.
75-
RUN npm install -g [email protected].0 --unsafe-perm=true
75+
RUN npm install -g [email protected].1 --unsafe-perm=true
7676

7777
ENV RUST_CONFIGURE_ARGS \
7878
--build=x86_64-unknown-linux-gnu \

src/test/rustdoc-gui/anchors.goml

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ assert-css: ("#impl a.anchor", {"color": "rgb(0, 0, 0)"})
3434
move-cursor-to: ".top-doc .docblock .section-header:first-child"
3535
assert-css: (
3636
".top-doc .docblock .section-header:first-child > a::before",
37-
{"left": "-10px", "padding-right": "10px"}
37+
{"left": "-10px", "padding-right": "10px"},
3838
)
3939
// We also check that the heading itself has a different indent.
4040
assert-css: (".top-doc .docblock .section-header:first-child", {"margin-left": "15px"})
4141

4242
move-cursor-to: ".top-doc .docblock .section-header:not(:first-child)"
4343
assert-css: (
4444
".top-doc .docblock .section-header:not(:first-child) > a::before",
45-
{"left": "-25px", "padding-right": "10px"}
45+
{"left": "-25px", "padding-right": "10px"},
4646
)
4747
assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-left": "0px"})
4848

@@ -51,14 +51,14 @@ assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-le
5151
move-cursor-to: "#title-for-struct-impl-doc"
5252
assert-css: (
5353
"#title-for-struct-impl-doc > a::before",
54-
{"left": "-25px", "padding-right": "10px"}
54+
{"left": "-25px", "padding-right": "10px"},
5555
)
5656
assert-css: ("#title-for-struct-impl-doc", {"margin-left": "0px"})
5757
// Now a method docs.
5858
move-cursor-to: "#title-for-struct-impl-item-doc"
5959
assert-css: (
6060
"#title-for-struct-impl-item-doc > a::before",
61-
{"left": "-25px", "padding-right": "10px"}
61+
{"left": "-25px", "padding-right": "10px"},
6262
)
6363
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
6464

@@ -69,6 +69,6 @@ goto: file://|DOC_PATH|/test_docs/enum.WhoLetTheDogOut.html
6969
move-cursor-to: ".top-doc .docblock .section-header"
7070
assert-css: (
7171
".top-doc .docblock .section-header > a::before",
72-
{"left": "-25px", "padding-right": "10px"}
72+
{"left": "-25px", "padding-right": "10px"},
7373
)
7474
assert-css: (".top-doc .docblock .section-header", {"margin-left": "0px"})

src/test/rustdoc-gui/docblock-code-block-line-number.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ wait-for: "pre.line-number"
1616
assert-css: ("pre.line-number", {
1717
"margin": "0px",
1818
"padding": "13px 8px",
19-
"text-align": "right"
19+
"text-align": "right",
2020
})
2121
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
2222
assert-text: ("pre.line-number", "1\n2")

src/test/rustdoc-gui/docblock-table-overflow.goml

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"})
1111
// Checking it works on other doc blocks as well...
1212

1313
// Logically, the ".docblock" and the "<p>" should have the same scroll width.
14-
compare-elements-property: ("#implementations + details .docblock", "#implementations + details .docblock > p", ["scrollWidth"])
14+
compare-elements-property: (
15+
"#implementations + details .docblock",
16+
"#implementations + details .docblock > p",
17+
["scrollWidth"],
18+
)
1519
assert-property: ("#implementations + details .docblock", {"scrollWidth": "816"})
1620
// However, since there is overflow in the <table>, its scroll width is bigger.
1721
assert-property: ("#implementations + details .docblock table", {"scrollWidth": "1573"})

src/test/rustdoc-gui/font-weight.goml

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
goto: file://|DOC_PATH|/lib2/struct.Foo.html
22
// This test checks that the font weight is correctly applied.
33
assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"})
4-
assert-css: ("//*[@class='structfield small-section-header']//a[text()='Alias']", {"font-weight": "400"})
4+
assert-css: (
5+
"//*[@class='structfield small-section-header']//a[text()='Alias']",
6+
{"font-weight": "400"},
7+
)
58
assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"})
69
assert-css: ("#associatedtype\.X > .code-header", {"font-weight": "600"})
710
assert-css: ("#associatedconstant\.Y > .code-header", {"font-weight": "600"})
@@ -25,8 +28,14 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html
2528
//
2629
// This uses '/parent::*' as a proxy for the style of the text node.
2730
// We can't just select the '<a>' because intermediate tags could be added.
28-
assert-count: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1)
29-
assert-css: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"})
31+
assert-count: (
32+
"//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*",
33+
1,
34+
)
35+
assert-css: (
36+
"//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*",
37+
{"font-weight": "400"},
38+
)
3039

3140
assert-count: (".methods .type", 1)
3241
assert-css: (".methods .type", {"font-weight": "600"})

src/test/rustdoc-gui/headers-color.goml

+63-13
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,36 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html
55
show-text: true
66

77
// Ayu theme
8-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
8+
local-storage: {
9+
"rustdoc-theme": "ayu",
10+
"rustdoc-preferred-dark-theme": "ayu",
11+
"rustdoc-use-system-theme": "false",
12+
}
913
reload:
1014

11-
assert-css: (".impl", {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, ALL)
12-
assert-css: (".impl .code-header", {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, ALL)
15+
assert-css: (
16+
".impl",
17+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"},
18+
ALL,
19+
)
20+
assert-css: (
21+
".impl .code-header",
22+
{"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"},
23+
ALL,
24+
)
1325

1426
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl
15-
assert-css: ("#impl", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"})
27+
assert-css: (
28+
"#impl",
29+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"},
30+
)
1631

1732
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
18-
assert-css: ("#method\.must_use", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, ALL)
33+
assert-css: (
34+
"#method\.must_use",
35+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"},
36+
ALL,
37+
)
1938

2039
goto: file://|DOC_PATH|/test_docs/index.html
2140
assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL)
@@ -24,17 +43,36 @@ goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
2443
assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL)
2544

2645
// Dark theme
27-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
46+
local-storage: {
47+
"rustdoc-theme": "dark",
48+
"rustdoc-preferred-dark-theme": "dark",
49+
"rustdoc-use-system-theme": "false",
50+
}
2851
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
2952

30-
assert-css: (".impl", {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, ALL)
31-
assert-css: (".impl .code-header", {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, ALL)
53+
assert-css: (
54+
".impl",
55+
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
56+
ALL,
57+
)
58+
assert-css: (
59+
".impl .code-header",
60+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"},
61+
ALL,
62+
)
3263

3364
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl
34-
assert-css: ("#impl", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"})
65+
assert-css: (
66+
"#impl",
67+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"},
68+
)
3569

3670
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
37-
assert-css: ("#method\.must_use", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, ALL)
71+
assert-css: (
72+
"#method\.must_use",
73+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"},
74+
ALL,
75+
)
3876

3977
goto: file://|DOC_PATH|/test_docs/index.html
4078
assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL)
@@ -48,14 +86,26 @@ reload:
4886

4987
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
5088

51-
assert-css: (".impl", {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, ALL)
52-
assert-css: (".impl .code-header", {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, ALL)
89+
assert-css: (
90+
".impl",
91+
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
92+
ALL,
93+
)
94+
assert-css: (
95+
".impl .code-header",
96+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"},
97+
ALL,
98+
)
5399

54100
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl
55101
assert-css: ("#impl", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"})
56102

57103
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
58-
assert-css: ("#method\.must_use", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, ALL)
104+
assert-css: (
105+
"#method\.must_use",
106+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"},
107+
ALL,
108+
)
59109

60110
goto: file://|DOC_PATH|/test_docs/index.html
61111
assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL)

src/test/rustdoc-gui/huge-collection-of-constants.goml

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ goto: file://|DOC_PATH|/test_docs/huge_amount_of_consts/index.html
22

33
// Make sure that the last two entries are more than 12 pixels apart and not stacked on each other.
44

5-
compare-elements-position-near-false: ("//*[@class='item-table']//div[last()-1]", "//*[@class='item-table']//div[last()-3]", {"y": 12})
5+
compare-elements-position-near-false: (
6+
"//*[@class='item-table']//div[last()-1]",
7+
"//*[@class='item-table']//div[last()-3]",
8+
{"y": 12},
9+
)

src/test/rustdoc-gui/jump-to-def-background.goml

+25-5
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,42 @@
22
goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html
33

44
// Set the theme to dark.
5-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
5+
local-storage: {
6+
"rustdoc-theme": "dark",
7+
"rustdoc-preferred-dark-theme": "dark",
8+
"rustdoc-use-system-theme": "false",
9+
}
610
// We reload the page so the local storage settings are being used.
711
reload:
812

9-
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL)
13+
assert-css: (
14+
"body.source .example-wrap pre.rust a",
15+
{"background-color": "rgb(51, 51, 51)"},
16+
ALL,
17+
)
1018

1119
// Set the theme to ayu.
12-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
20+
local-storage: {
21+
"rustdoc-theme": "ayu",
22+
"rustdoc-preferred-dark-theme": "ayu",
23+
"rustdoc-use-system-theme": "false",
24+
}
1325
// We reload the page so the local storage settings are being used.
1426
reload:
1527

16-
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL)
28+
assert-css: (
29+
"body.source .example-wrap pre.rust a",
30+
{"background-color": "rgb(51, 51, 51)"},
31+
ALL,
32+
)
1733

1834
// Set the theme to light.
1935
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
2036
// We reload the page so the local storage settings are being used.
2137
reload:
2238

23-
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(238, 238, 238)"}, ALL)
39+
assert-css: (
40+
"body.source .example-wrap pre.rust a",
41+
{"background-color": "rgb(238, 238, 238)"},
42+
ALL,
43+
)

src/test/rustdoc-gui/label-next-to-symbol.goml

+53-11
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,71 @@ assert: (".stab.deprecated")
88
assert: (".stab.portability")
99

1010
// make sure that deprecated and portability are different colours
11-
assert-css: (".item-table .item-left .stab.deprecated", { "background-color": "rgb(255, 196, 196)" })
12-
assert-css: (".item-table .item-left .stab.portability", { "background-color": "rgb(243, 223, 255)" })
11+
assert-css: (
12+
".item-table .item-left .stab.deprecated",
13+
{ "background-color": "rgb(255, 196, 196)" },
14+
)
15+
assert-css: (
16+
".item-table .item-left .stab.portability",
17+
{ "background-color": "rgb(243, 223, 255)" },
18+
)
1319

1420
// table like view
1521
assert-css: (".item-right.docblock-short", { "padding-left": "0px" })
16-
compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", {"y": 2})
17-
compare-elements-position: (".item-left .stab.deprecated", ".item-left .stab.portability", ("y"))
22+
compare-elements-position-near: (
23+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
24+
".item-left .stab.deprecated",
25+
{"y": 2},
26+
)
27+
compare-elements-position: (
28+
".item-left .stab.deprecated",
29+
".item-left .stab.portability",
30+
("y"),
31+
)
1832

1933
// Ensure no wrap
20-
compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", {"y": 2})
34+
compare-elements-position-near: (
35+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
36+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']",
37+
{"y": 2},
38+
)
2139
// compare parent elements
22-
compare-elements-position: ("//*[@class='item-left module-item']//a[text()='replaced_function']/..", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", ("y"))
40+
compare-elements-position: (
41+
"//*[@class='item-left module-item']//a[text()='replaced_function']/..",
42+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..",
43+
("y"),
44+
)
2345

2446

2547
// Mobile view
2648
size: (600, 600)
2749
// staggered layout with 2em spacing
2850
assert-css: (".item-right.docblock-short", { "padding-left": "32px" })
29-
compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", {"y": 1})
30-
compare-elements-position: (".item-left .stab.deprecated", ".item-left .stab.portability", ("y"))
51+
compare-elements-position-near: (
52+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
53+
".item-left .stab.deprecated",
54+
{"y": 1},
55+
)
56+
compare-elements-position: (
57+
".item-left .stab.deprecated",
58+
".item-left .stab.portability",
59+
("y"),
60+
)
3161

3262
// Ensure wrap
33-
compare-elements-position-near-false: ("//*[@class='item-left module-item']//a[text()='replaced_function']", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", {"y": 12})
63+
compare-elements-position-near-false: (
64+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
65+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']",
66+
{"y": 12},
67+
)
3468
// compare parent elements
35-
compare-elements-position-false: ("//*[@class='item-left module-item']//a[text()='replaced_function']/..", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", ("y"))
36-
compare-elements-position-false: (".item-left .stab.deprecated", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", ("y"))
69+
compare-elements-position-false: (
70+
"//*[@class='item-left module-item']//a[text()='replaced_function']/..",
71+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..",
72+
("y"),
73+
)
74+
compare-elements-position-false: (
75+
".item-left .stab.deprecated",
76+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']",
77+
("y"),
78+
)

0 commit comments

Comments
 (0)