Skip to content

Commit 8f3c2cc

Browse files
authored
Rollup merge of #85191 - GuillaumeGomez:improve-rustdoc-gui-tester, r=Mark-Simulacrum
Improve rustdoc gui tester I cherry-picked the commit from #84834 (and modified it a bit). I also used this opportunity to update it to last version (forgot to update GUI test in #85074, really can't wait to make #84586 finally work). cc `@Mark-Simulacrum` for the changes in bootstrap. r? `@jsha`
2 parents c4c654f + 6b94990 commit 8f3c2cc

16 files changed

+43
-27
lines changed

src/bootstrap/test.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -827,17 +827,30 @@ impl Step for RustdocGUI {
827827
}
828828

829829
let out_dir = builder.test_out(self.target).join("rustdoc-gui");
830-
let mut command = builder.rustdoc_cmd(self.compiler);
831-
command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir);
832-
builder.run(&mut command);
833830

831+
// We remove existing folder to be sure there won't be artifacts remaining.
832+
let _ = fs::remove_dir_all(&out_dir);
833+
834+
// We generate docs for the libraries present in the rustdoc-gui's src folder.
835+
let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src");
836+
for entry in libs_dir.read_dir().expect("read_dir call failed") {
837+
let entry = entry.expect("invalid entry");
838+
let path = entry.path();
839+
if path.extension().map(|e| e == "rs").unwrap_or(false) {
840+
let mut command = builder.rustdoc_cmd(self.compiler);
841+
command.arg(path).arg("-o").arg(&out_dir);
842+
builder.run(&mut command);
843+
}
844+
}
845+
846+
// We now run GUI tests.
834847
let mut command = Command::new(&nodejs);
835848
command
836-
.arg("src/tools/rustdoc-gui/tester.js")
849+
.arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
837850
.arg("--doc-folder")
838-
.arg(out_dir.join("test_docs"))
851+
.arg(out_dir)
839852
.arg("--tests-folder")
840-
.arg("src/test/rustdoc-gui");
853+
.arg(builder.build.src.join("src/test/rustdoc-gui"));
841854
builder.run(&mut command);
842855
} else {
843856
builder.info("No nodejs found, skipping \"src/test/rustdoc-gui\" tests");

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

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

src/test/rustdoc-gui/basic.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
22
assert: ("#functions")
33
goto: ./struct.Foo.html
44
assert: ("div.type-decl")

src/test/rustdoc-gui/check_info_sign_position.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
22
goto: ./fn.check_list_code_block.html
33
// If the codeblock is the first element of the docblock, the information tooltip must have
44
// have some top margin to avoid going over the toggle (the "[+]").

src/test/rustdoc-gui/code-sidebar-toggle.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
22
click: ".srclink"
33
click: "#sidebar-toggle"
44
wait-for: 500

src/test/rustdoc-gui/hash-item-expansion.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This test ensures that the element corresponding to the hash is displayed.
2-
goto: file://|DOC_PATH|/struct.Foo.html#method.borrow
2+
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow
33
// In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)".
44
assert: ("#blanket-implementations-list > details:nth-child(2)", "open", "")
55
// Please note the "\" below is needed because otherwise ".borrow" would be interpreted as
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This test ensures that the impl blocks are open by default.
2-
goto: file://|DOC_PATH|/struct.Foo.html
2+
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
33
assert: ("#main > details.implementors-toggle", "open", "")
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
22
goto: ./fn.check_list_code_block.html
33
assert: ("pre.rust.fn")

src/test/rustdoc-gui/search-input-mobile.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test to ensure that you can click on the search input, whatever the width.
22
// The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592
3-
goto: file://|DOC_PATH|/index.html
3+
goto: file://|DOC_PATH|/test_docs/index.html
44
size: (463, 700)
55
// We first check that the search input isn't already focused.
66
assert-false: ("input.search-input:focus")

src/test/rustdoc-gui/search-tab-selection-if-current-is-empty.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
22
write: (".search-input", "Foo")
33
// Waiting for the search results to appear...
44
wait-for: "#titles"
55
assert: ("#titles > button:nth-of-type(1)", "class", "selected")
66

77
// To go back to the original "state"
8-
goto: file://|DOC_PATH|/index.html
8+
goto: file://|DOC_PATH|/test_docs/index.html
99
write: (".search-input", "-> String")
1010
// Waiting for the search results to appear...
1111
wait-for: "#titles"
1212
// With this search, only the last tab shouldn't be empty so it should be selected.
1313
assert: ("#titles > button:nth-of-type(3)", "class", "selected")
1414

1515
// To go back to the original "state"
16-
goto: file://|DOC_PATH|/index.html
16+
goto: file://|DOC_PATH|/test_docs/index.html
1717
write: (".search-input", "-> Something")
1818
// Waiting for the search results to appear...
1919
wait-for: "#titles"

src/test/rustdoc-gui/shortcuts.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Check that the various shortcuts are working.
2-
goto: file://|DOC_PATH|/index.html
2+
goto: file://|DOC_PATH|/test_docs/index.html
33
// We first check that the search input isn't already focused.
44
assert-false: "input.search-input:focus"
55
press-key: "s"

src/test/rustdoc-gui/source-code-page.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
goto: file://|DOC_PATH|/../src/test_docs/lib.rs.html
1+
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
22
// Check that we can click on the line number.
33
click: (40, 224) // This is the position of the span for line 4.
44
// Unfortunately, "#4" isn't a valid query selector, so we have to go around that limitation
55
// by instead getting the nth span.
66
assert: (".line-numbers > span:nth-child(4)", "class", "line-highlighted")
77
// We now check that the good spans are highlighted
8-
goto: file://|DOC_PATH|/../src/test_docs/lib.rs.html#4-6
8+
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html#4-6
99
assert-false: (".line-numbers > span:nth-child(3)", "class", "line-highlighted")
1010
assert: (".line-numbers > span:nth-child(4)", "class", "line-highlighted")
1111
assert: (".line-numbers > span:nth-child(5)", "class", "line-highlighted")
File renamed without changes.

src/test/rustdoc-gui/theme-change.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
22
click: "#theme-picker"
33
click: "#theme-choices > button:first-child"
44
wait-for: 500

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
goto: file://|DOC_PATH|/index.html
1+
goto: file://|DOC_PATH|/test_docs/index.html
2+
assert: ("#main > details.top-doc", "open", "")
23
click: "#toggle-all-docs"
3-
wait-for: 5000
4-
assert: ("#main > div.docblock.hidden-by-usual-hider")
4+
wait-for: 1000
5+
// This is now collapsed so there shouldn't be the "open" attribute on details.
6+
assert-false: ("#main > details.top-doc", "open", "")
57
click: "#toggle-all-docs"
6-
wait-for: 5000
7-
assert: ("#main > div.docblock.hidden-by-usual-hider", 0)
8+
wait-for: 1000
9+
// Not collapsed anymore so the "open" attribute should be back.
10+
assert: ("#main > details.top-doc", "open", "")

src/test/rustdoc-gui/trait-sidebar-item-order.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
goto: file://|DOC_PATH|/trait.AnotherOne.html
1+
goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
22
assert: (".sidebar-links a:nth-of-type(1)", "another")
33
assert: (".sidebar-links a:nth-of-type(2)", "func1")
44
assert: (".sidebar-links a:nth-of-type(3)", "func2")

0 commit comments

Comments
 (0)