Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d332b90

Browse files
authoredOct 28, 2024··
Unrolled build for rust-lang#132220
Rollup merge of rust-lang#132220 - GuillaumeGomez:gui-test-struct-fields-margins, r=notriddle Add GUI regression test for doc struct fields margins Fixes rust-lang#131402. r? `@notriddle`
2 parents 6929a48 + c50bfda commit d332b90

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed
 

‎tests/rustdoc-gui/fields.goml

+40-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1-
// This test checks that fields are displayed as expected (one by line).
2-
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html"
3-
store-position: ("#structfield\.a", {"y": a_y})
4-
store-position: ("#structfield\.b", {"y": b_y})
5-
assert: |a_y| < |b_y|
1+
// This test checks that fields are displayed as expected (one by line) and they are surrounded
2+
// by margins.
63

7-
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/union.Union.html"
8-
store-position: ("#structfield\.a", {"y": a_y})
9-
store-position: ("#structfield\.b", {"y": b_y})
10-
assert: |a_y| < |b_y|
4+
define-function: (
5+
"check-fields",
6+
[path, selector_1, selector_2],
7+
block {
8+
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/" + |path|
9+
store-position: (|selector_1|, {"y": a_y})
10+
store-position: (|selector_2|, {"y": b_y})
11+
assert: |a_y| < |b_y|
12+
13+
// Check the margins.
14+
assert-css: (".structfield.section-header", {
15+
"margin-top": "9.6px",
16+
"margin-bottom": "9.6px",
17+
"margin-left": "0px",
18+
"margin-right": "0px",
19+
}, ALL)
20+
}
21+
)
22+
23+
call-function: ("check-fields", {
24+
"path": "struct.Struct.html",
25+
"selector_1": "#structfield\.a",
26+
"selector_2": "#structfield\.b",
27+
})
28+
29+
call-function: ("check-fields", {
30+
"path": "union.Union.html",
31+
"selector_1": "#structfield\.a",
32+
"selector_2": "#structfield\.b",
33+
})
1134

1235
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/enum.Enum.html"
1336
store-position: ("#variant\.A\.field\.a", {"y": a_y})
@@ -16,3 +39,11 @@ assert: |a_y| < |b_y|
1639
store-position: ("#variant\.B\.field\.a", {"y": a_y})
1740
store-position: ("#variant\.B\.field\.b", {"y": b_y})
1841
assert: |a_y| < |b_y|
42+
43+
// Check the margins.
44+
assert-css: (".sub-variant-field .section-header", {
45+
"margin-top": "0px",
46+
"margin-bottom": "0px",
47+
"margin-left": "0px",
48+
"margin-right": "0px",
49+
}, ALL)

‎tests/rustdoc-gui/struct-fields.goml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// This test ensures that each field is on its own line (In other words, they have display: block).
1+
// This test ensures that each field is on its own line (In other words, they have
2+
// `display: block`).
23
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html"
34

45
store-property: ("//*[@id='structfield.first']", {"offsetTop": first_top})

0 commit comments

Comments
 (0)
Please sign in to comment.