Skip to content

Commit

Permalink
Add tests for case insensitive support
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Mar 28, 2021
1 parent 3b8de99 commit 106da77
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 15 deletions.
23 changes: 19 additions & 4 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,24 @@ impl Step for RustdocGUI {
}

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

for file in fs::read_dir("src/test/rustdoc-gui").unwrap() {
let file = file.unwrap();
let file_name = file.file_name();

if !file_name.to_str().unwrap().ends_with(".rs") {
continue;
}

let mut command = builder.rustdoc_cmd(self.compiler);
command
.arg(&Path::new("src/test/rustdoc-gui").join(file_name))
.arg("-o")
.arg(&out_dir)
.arg("-Zunstable-options")
.arg("--generate-case-insensitive");
builder.run(&mut command);
}

for file in fs::read_dir("src/test/rustdoc-gui").unwrap() {
let file = file.unwrap();
Expand All @@ -750,7 +765,7 @@ impl Step for RustdocGUI {
command
.arg("src/tools/rustdoc-gui/tester.js")
.arg("--doc-folder")
.arg(out_dir.join("test_docs"))
.arg(&out_dir)
.arg("--test-file")
.arg(file_path);
builder.run(&mut command);
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/basic-code.goml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
click: ".srclink"
assert: (".line-numbers", 1)
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/basic.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
assert: ("#functions")
goto: ./struct.Foo.html
assert: ("div.type-decl")
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/check_info_sign_position.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
goto: ./fn.check_list_code_block.html
// If the codeblock is the first element of the docblock, the information tooltip must have
// have some top margin to avoid going over the toggle (the "[+]").
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/code-sidebar-toggle.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
click: ".srclink"
click: "#sidebar-toggle"
wait-for: 500
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc-gui/insensitive-case-check.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
goto: file://|DOC_PATH|/insensitive_case_docs/struct.ab.html
// Checks that the sidebar was filled.
wait-for: ".sidebar-elems > .items > .sidebar-title"
// Checks that the content has been loaded
assert: ".impl-items > h4"
// Checks that the collapse toggles have been generated as expected
assert: ".impl-items > h4 > .collapse-toggle"
19 changes: 19 additions & 0 deletions src/test/rustdoc-gui/insensitive-test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! The point of this crate is to test the insensitive case handling.

#![crate_name = "insensitive_case_docs"]

#![allow(non_camel_case_types)]

/// This is ab.
pub struct ab;

impl ab {
pub fn foo(&self) {}
}

/// This is another Ab!
pub struct Ab;

impl Ab {
pub fn bar(&self) {}
}
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/list_code_block.goml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
goto: ./fn.check_list_code_block.html
assert: ("pre.rust.fn")
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/nojs-attr-pos.goml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Check that the attributes are well positioned when javascript is disabled (since
// there is no toggle to display)
javascript: false
goto: file://|DOC_PATH|/struct.Foo.html
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
assert: (".attributes", {"margin-left": "0px"})
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/search-input-mobile.goml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test to ensure that you can click on the search input, whatever the width.
// The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
size: (463, 700)
// We first check that the search input isn't already focused.
assert-false: ("input.search-input:focus")
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/shortcuts.goml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Check that the various shortcuts are working.
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
// We first check that the search input isn't already focused.
assert-false: "input.search-input:focus"
press-key: "s"
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/theme-change.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
click: "#theme-picker"
click: "#theme-choices > button:first-child"
wait-for: 500
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/toggle-docs.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goto: file://|DOC_PATH|/index.html
goto: file://|DOC_PATH|/test_docs/index.html
click: "#toggle-all-docs"
wait-for: 5000
assert: ("#main > div.docblock.hidden-by-usual-hider")
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/trait-sidebar-item-order.goml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
goto: file://|DOC_PATH|/trait.AnotherOne.html
goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
assert: (".sidebar-links a:nth-of-type(1)", "another")
assert: (".sidebar-links a:nth-of-type(2)", "func1")
assert: (".sidebar-links a:nth-of-type(3)", "func2")
Expand Down
18 changes: 18 additions & 0 deletions src/test/rustdoc/insensitive-case.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// compile-flags: -Zunstable-options --generate-case-insensitive

#![crate_name = "foo"]

// @!has 'foo/struct.Aa.html'
// @has 'foo/struct.aa.html'
// @!has 'foo/struct.aa.html' '//h4[@id="method.new"]'
pub struct aa;

impl aa {
pub fn foo(&self) {}
}

pub struct Aa;

impl Aa {
pub fn foo(&self) {}
}

0 comments on commit 106da77

Please sign in to comment.