Skip to content

Commit

Permalink
Unrolled build for rust-lang#132220
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
rust-timer authored Oct 28, 2024
2 parents 6929a48 + c50bfda commit d332b90
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
49 changes: 40 additions & 9 deletions tests/rustdoc-gui/fields.goml
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
// This test checks that fields are displayed as expected (one by line).
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html"
store-position: ("#structfield\.a", {"y": a_y})
store-position: ("#structfield\.b", {"y": b_y})
assert: |a_y| < |b_y|
// This test checks that fields are displayed as expected (one by line) and they are surrounded
// by margins.

go-to: "file://" + |DOC_PATH| + "/test_docs/fields/union.Union.html"
store-position: ("#structfield\.a", {"y": a_y})
store-position: ("#structfield\.b", {"y": b_y})
assert: |a_y| < |b_y|
define-function: (
"check-fields",
[path, selector_1, selector_2],
block {
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/" + |path|
store-position: (|selector_1|, {"y": a_y})
store-position: (|selector_2|, {"y": b_y})
assert: |a_y| < |b_y|

// Check the margins.
assert-css: (".structfield.section-header", {
"margin-top": "9.6px",
"margin-bottom": "9.6px",
"margin-left": "0px",
"margin-right": "0px",
}, ALL)
}
)

call-function: ("check-fields", {
"path": "struct.Struct.html",
"selector_1": "#structfield\.a",
"selector_2": "#structfield\.b",
})

call-function: ("check-fields", {
"path": "union.Union.html",
"selector_1": "#structfield\.a",
"selector_2": "#structfield\.b",
})

go-to: "file://" + |DOC_PATH| + "/test_docs/fields/enum.Enum.html"
store-position: ("#variant\.A\.field\.a", {"y": a_y})
Expand All @@ -16,3 +39,11 @@ assert: |a_y| < |b_y|
store-position: ("#variant\.B\.field\.a", {"y": a_y})
store-position: ("#variant\.B\.field\.b", {"y": b_y})
assert: |a_y| < |b_y|

// Check the margins.
assert-css: (".sub-variant-field .section-header", {
"margin-top": "0px",
"margin-bottom": "0px",
"margin-left": "0px",
"margin-right": "0px",
}, ALL)
3 changes: 2 additions & 1 deletion tests/rustdoc-gui/struct-fields.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This test ensures that each field is on its own line (In other words, they have display: block).
// This test ensures that each field is on its own line (In other words, they have
// `display: block`).
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.StructWithPublicUndocumentedFields.html"

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

0 comments on commit d332b90

Please sign in to comment.