Skip to content

Commit 106da77

Browse files
Add tests for case insensitive support
1 parent 3b8de99 commit 106da77

15 files changed

+74
-15
lines changed

src/bootstrap/test.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,24 @@ impl Step for RustdocGUI {
734734
}
735735

736736
let out_dir = builder.test_out(self.target).join("rustdoc-gui");
737-
let mut command = builder.rustdoc_cmd(self.compiler);
738-
command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir);
739-
builder.run(&mut command);
737+
738+
for file in fs::read_dir("src/test/rustdoc-gui").unwrap() {
739+
let file = file.unwrap();
740+
let file_name = file.file_name();
741+
742+
if !file_name.to_str().unwrap().ends_with(".rs") {
743+
continue;
744+
}
745+
746+
let mut command = builder.rustdoc_cmd(self.compiler);
747+
command
748+
.arg(&Path::new("src/test/rustdoc-gui").join(file_name))
749+
.arg("-o")
750+
.arg(&out_dir)
751+
.arg("-Zunstable-options")
752+
.arg("--generate-case-insensitive");
753+
builder.run(&mut command);
754+
}
740755

741756
for file in fs::read_dir("src/test/rustdoc-gui").unwrap() {
742757
let file = file.unwrap();
@@ -750,7 +765,7 @@ impl Step for RustdocGUI {
750765
command
751766
.arg("src/tools/rustdoc-gui/tester.js")
752767
.arg("--doc-folder")
753-
.arg(out_dir.join("test_docs"))
768+
.arg(&out_dir)
754769
.arg("--test-file")
755770
.arg(file_path);
756771
builder.run(&mut command);

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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
goto: file://|DOC_PATH|/insensitive_case_docs/struct.ab.html
2+
// Checks that the sidebar was filled.
3+
wait-for: ".sidebar-elems > .items > .sidebar-title"
4+
// Checks that the content has been loaded
5+
assert: ".impl-items > h4"
6+
// Checks that the collapse toggles have been generated as expected
7+
assert: ".impl-items > h4 > .collapse-toggle"
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! The point of this crate is to test the insensitive case handling.
2+
3+
#![crate_name = "insensitive_case_docs"]
4+
5+
#![allow(non_camel_case_types)]
6+
7+
/// This is ab.
8+
pub struct ab;
9+
10+
impl ab {
11+
pub fn foo(&self) {}
12+
}
13+
14+
/// This is another Ab!
15+
pub struct Ab;
16+
17+
impl Ab {
18+
pub fn bar(&self) {}
19+
}
+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")
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Check that the attributes are well positioned when javascript is disabled (since
22
// there is no toggle to display)
33
javascript: false
4-
goto: file://|DOC_PATH|/struct.Foo.html
4+
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
55
assert: (".attributes", {"margin-left": "0px"})

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/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/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

+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: "#toggle-all-docs"
33
wait-for: 5000
44
assert: ("#main > div.docblock.hidden-by-usual-hider")

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")

src/test/rustdoc/insensitive-case.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// compile-flags: -Zunstable-options --generate-case-insensitive
2+
3+
#![crate_name = "foo"]
4+
5+
// @!has 'foo/struct.Aa.html'
6+
// @has 'foo/struct.aa.html'
7+
// @!has 'foo/struct.aa.html' '//h4[@id="method.new"]'
8+
pub struct aa;
9+
10+
impl aa {
11+
pub fn foo(&self) {}
12+
}
13+
14+
pub struct Aa;
15+
16+
impl Aa {
17+
pub fn foo(&self) {}
18+
}

0 commit comments

Comments
 (0)