Skip to content

Commit

Permalink
Extend GUI tests for doc_cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 7, 2023
1 parent bf681dc commit 9e1797b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/rustdoc-gui/item-info.goml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ assert-size: (".item-info", {"width": 840})
assert-size: (".item-info .stab", {"width": 289})
assert-position: (".item-info .stab", {"x": 245})

// We check that the display of the feature elements is not broken. It serves as regression
// test for <https://github.com/rust-lang/rust/issues/118615>.
set-window-size: (850, 800)
store-position: (
"//*[@class='stab portability']//code[text()='Win32_System']",
{"x": first_line_x, "y": first_line_y},
)
store-position: (
"//*[@class='stab portability']//code[text()='Win32_System_Diagnostics']",
{"x": second_line_x, "y": second_line_y},
)
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
assert: |first_line_y| != |second_line_y| && |first_line_y| == 688 && |second_line_y| == 711

// Now we ensure that they're not rendered on the same line.
set-window-size: (1100, 800)
go-to: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html"
// We first ensure that there are two item info on the trait.
assert-count: ("#main-content > .item-info .stab", 2)
Expand Down
7 changes: 7 additions & 0 deletions tests/rustdoc-gui/src/lib2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ edition = "2018"
[lib]
path = "lib.rs"

[features]
Win32 = ["Win32_System"]
Win32_System = ["Win32_System_Diagnostics"]
Win32_System_Diagnostics = ["Win32_System_Diagnostics_Debug"]
Win32_System_Diagnostics_Debug = []
default = ["Win32"]

[dependencies]
implementors = { path = "./implementors" }
http = { path = "./http" }
9 changes: 9 additions & 0 deletions tests/rustdoc-gui/src/lib2/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore-tidy-linelength

#![feature(doc_cfg)]
#![feature(doc_auto_cfg)]

pub mod another_folder;
pub mod another_mod;
Expand Down Expand Up @@ -28,6 +29,14 @@ impl Foo {
/// Some documentation
/// # A Heading
pub fn a_method(&self) {}

#[cfg(all(
feature = "Win32",
feature = "Win32_System",
feature = "Win32_System_Diagnostics",
feature = "Win32_System_Diagnostics_Debug"
))]
pub fn lot_of_features() {}
}

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

0 comments on commit 9e1797b

Please sign in to comment.