Skip to content

Commit 5d0a044

Browse files
Add GUI regression test for scraped examples intra doc links
1 parent ae9f844 commit 5d0a044

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test checks the intra doc links to code examples.
2+
go-to: "file://" + |DOC_PATH| + "/scrape_examples/index.html"
3+
4+
assert-attribute: (
5+
"//a[text()='check']",
6+
{
7+
"href": "../src/check/check.rs.html",
8+
"title": "Example check",
9+
},
10+
)
11+
assert-attribute: (
12+
"//a[text()='check/check.rs']",
13+
{
14+
"href": "../src/check/check.rs.html",
15+
"title": "Example check",
16+
},
17+
)
18+
assert-attribute: (
19+
"//a[text()='check/sub.rs']",
20+
{
21+
"href": "../src/check/sub.rs.html",
22+
"title": "Example check",
23+
},
24+
)
25+
// We now click on the link to ensure it works.
26+
click: "//a[text()='check/sub.rs']"
27+
wait-for-text: (".main-heading h1", "check/sub.rs")

tests/rustdoc-gui/src/scrape_examples/examples/check.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
mod sub;
2+
13
fn main() {
4+
sub::foo();
5+
26
for i in 0..9 {
37
println!("hello world!");
48
println!("hello world!");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn foo() {}

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

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//@ run-flags:-Zrustdoc-scrape-examples
2+
3+
//! [example@check] [example@check/check.rs] [example@check/sub.rs]
4+
25
/// # Examples
36
///
47
/// ```

0 commit comments

Comments
 (0)