Skip to content

Commit 8005092

Browse files
Add rustdoc gui tests
1 parent fa13184 commit 8005092

File tree

7 files changed

+100
-0
lines changed

7 files changed

+100
-0
lines changed

src/test/rustdoc-gui/basic-code.goml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
goto: file://|DOC_PATH|/index.html
2+
click: ".srclink"
3+
assert: (".line-numbers", 1)

src/test/rustdoc-gui/basic.goml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
goto: file://|DOC_PATH|/index.html
2+
assert: ("#functions")
3+
goto: ./struct.Foo.html
4+
assert: ("div.type-decl")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
goto: file://|DOC_PATH|/index.html
2+
click: ".srclink"
3+
click: "#sidebar-toggle"
4+
wait-for: 500
5+
fail: true
6+
assert: ("#source-sidebar", { "left": "-300px" })

src/test/rustdoc-gui/lib.rs

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//! The point of this crate is to be able to have enough different "kinds" of
2+
//! documentation generated so we can test each different features.
3+
4+
#![crate_name = "test_docs"]
5+
6+
use std::fmt;
7+
8+
/// Basic function with some code examples:
9+
///
10+
/// ```
11+
/// println!("nothing fancy");
12+
/// ```
13+
///
14+
/// A failing to compile one:
15+
///
16+
/// ```compile_fail
17+
/// println!("where did my argument {} go? :'(");
18+
/// ```
19+
///
20+
/// An ignored one:
21+
///
22+
/// ```ignore (it's a test)
23+
/// Let's say I'm just some text will ya?
24+
/// ```
25+
pub fn foo() {}
26+
27+
/// Just a normal struct.
28+
pub struct Foo;
29+
30+
/// Just a normal enum.
31+
pub enum WhoLetTheDogOut {
32+
/// Woof!
33+
Woof,
34+
/// Meoooooooow...
35+
Meow,
36+
}
37+
38+
/// Who doesn't love to wrap a `format!` call?
39+
pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
40+
format!("{:?}", t)
41+
}
42+
43+
/// Woohoo! A trait!
44+
pub trait AnotherOne {
45+
/// Some func 1.
46+
fn func1();
47+
48+
/// Some func 2.
49+
fn func2();
50+
51+
/// Some func 3.
52+
fn func3();
53+
}
54+
55+
/// Check for "i" signs in lists!
56+
///
57+
/// 1. elem 1
58+
/// 2.test 1
59+
/// ```compile_fail
60+
/// fn foo() {}
61+
/// ```
62+
/// 3. elem 3
63+
/// 4. ```ignore (it's a test)
64+
/// fn foo() {}
65+
/// ```
66+
/// 5. elem 5
67+
pub fn check_list_code_block() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
goto: file://|DOC_PATH|/index.html
2+
goto: ./fn.check_list_code_block.html
3+
assert: ("pre.rust.fn")
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
goto: file://|DOC_PATH|/index.html
2+
click: "#theme-picker"
3+
click: "#theme-choices > button:first-child"
4+
wait-for: 500
5+
// should be the ayu theme so let's check the color
6+
assert: ("body", { "background-color": "rgb(15, 20, 25)" })
7+
click: "#theme-choices > button:last-child"
8+
wait-for: 500
9+
// should be the light theme so let's check the color
10+
assert: ("body", { "background-color": "rgb(255, 255, 255)" })

src/test/rustdoc-gui/toggle-docs.goml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
goto: file://|DOC_PATH|/index.html
2+
click: "#toggle-all-docs"
3+
wait-for: 5000
4+
assert: ("#main > div.docblock.hidden-by-usual-hider")
5+
click: "#toggle-all-docs"
6+
wait-for: 5000
7+
assert: ("#main > div.docblock.hidden-by-usual-hider", 0)

0 commit comments

Comments
 (0)