Skip to content

Commit 9e482c1

Browse files
* Enable generate-link-to-def feature on a rustdoc GUI test
* Add test for jump-to-def links background color
1 parent 6a2f500 commit 9e482c1

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

Diff for: src/bootstrap/test.rs

+5
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,11 @@ impl Step for RustdocGUI {
925925
.env("RUSTDOC", builder.rustdoc(self.compiler))
926926
.env("RUSTC", builder.rustc(self.compiler))
927927
.current_dir(path);
928+
// FIXME: implement a `// compile-flags` command or similar
929+
// instead of hard-coding this test
930+
if entry.file_name() == "link_to_definition" {
931+
cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
932+
}
928933
builder.run(&mut cargo);
929934
}
930935
}

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

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// We check the background color on the jump to definition links in the source code page.
2+
goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html
3+
4+
// Set the theme to dark.
5+
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
6+
// We reload the page so the local storage settings are being used.
7+
reload:
8+
9+
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL)
10+
11+
// Set the theme to ayu.
12+
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
13+
// We reload the page so the local storage settings are being used.
14+
reload:
15+
16+
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL)
17+
18+
// Set the theme to light.
19+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
20+
// We reload the page so the local storage settings are being used.
21+
reload:
22+
23+
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(238, 238, 238)"}, ALL)
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "link_to_definition"
7+
version = "0.1.0"
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "link_to_definition"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
path = "lib.rs"

Diff for: src/test/rustdoc-gui/src/link_to_definition/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pub struct Bar {
2+
pub a: String,
3+
pub b: u32,
4+
}
5+
6+
pub fn foo(_b: &Bar) {}

0 commit comments

Comments
 (0)