Skip to content

Commit 42989b7

Browse files
Extend GUI tests for doc_cfg
1 parent 9beb9bb commit 42989b7

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

tests/rustdoc-gui/item-info.goml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,26 @@ go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html"
33
// Ensuring that the item information don't take 100% of the width if unnecessary.
44
// We set a fixed size so there is no chance of "random" resize.
55
set-window-size: (1100, 800)
6-
// We check that ".item-info" is bigger than its content.
76
assert-size: (".item-info", {"width": 840})
8-
assert-size: (".item-info .stab", {"width": 289})
7+
assert-size: (".item-info .stab", {"width": 840})
98
assert-position: (".item-info .stab", {"x": 245})
109

10+
// We check that the display of the feature elements is not broken. It serves as regression
11+
// test for <https://github.com/rust-lang/rust/issues/118615>.
12+
set-window-size: (850, 800)
13+
store-position: (
14+
"//*[@class='stab portability']//code[text()='Win32_System']",
15+
{"x": first_line_x, "y": first_line_y},
16+
)
17+
store-position: (
18+
"//*[@class='stab portability']//code[text()='Win32_System_Diagnostics']",
19+
{"x": second_line_x, "y": second_line_y},
20+
)
21+
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
22+
assert: |first_line_y| != |second_line_y| && |first_line_y| == 672 && |second_line_y| == 693
23+
1124
// Now we ensure that they're not rendered on the same line.
25+
set-window-size: (1100, 800)
1226
go-to: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html"
1327
// We first ensure that there are two item info on the trait.
1428
assert-count: ("#main-content > .item-info .stab", 2)

tests/rustdoc-gui/src/lib2/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ edition = "2018"
66
[lib]
77
path = "lib.rs"
88

9+
[features]
10+
Win32 = ["Win32_System"]
11+
Win32_System = ["Win32_System_Diagnostics"]
12+
Win32_System_Diagnostics = ["Win32_System_Diagnostics_Debug"]
13+
Win32_System_Diagnostics_Debug = []
14+
default = ["Win32"]
15+
916
[dependencies]
1017
implementors = { path = "./implementors" }
1118
http = { path = "./http" }

tests/rustdoc-gui/src/lib2/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ignore-tidy-linelength
22

33
#![feature(doc_cfg)]
4+
#![feature(doc_auto_cfg)]
45

56
pub mod another_folder;
67
pub mod another_mod;
@@ -28,6 +29,14 @@ impl Foo {
2829
/// Some documentation
2930
/// # A Heading
3031
pub fn a_method(&self) {}
32+
33+
#[cfg(all(
34+
feature = "Win32",
35+
feature = "Win32_System",
36+
feature = "Win32_System_Diagnostics",
37+
feature = "Win32_System_Diagnostics_Debug"
38+
))]
39+
pub fn lot_of_features() {}
3140
}
3241

3342
#[doc(cfg(feature = "foo-method"))]

0 commit comments

Comments
 (0)