Skip to content

Commit

Permalink
Auto merge of #12800 - notriddle:notriddle/version-tests, r=ehuss
Browse files Browse the repository at this point in the history
rustdoc: remove the word "Version" from test cases

Needed for rust-lang/rust#115948 to merge.

That PR gets rid of the word "Version" in rustdoc's HTML output, and it splits spaced versions on their first space, to fit in the tight horizontal spacing. This causes Cargo's test suite to fail, because it look for the word "Version", even though things are working as they should.

These tests work on both current nightly and on that pull request.
  • Loading branch information
bors committed Oct 10, 2023
2 parents c97c906 + f0d3cdf commit e4fe8f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,7 @@ fn crate_versions() {
let output_path = p.root().join("target/doc/foo/index.html");
let output_documentation = fs::read_to_string(&output_path).unwrap();

assert!(output_documentation.contains("Version 1.2.4"));
assert!(output_documentation.contains("1.2.4"));
}

#[cargo_test]
Expand All @@ -2028,7 +2028,7 @@ fn crate_versions_flag_is_overridden() {
};
let asserts = |html: String| {
assert!(!html.contains("1.2.4"));
assert!(html.contains("Version 2.0.3"));
assert!(html.contains("2.0.3"));
};

p.cargo("doc")
Expand Down
8 changes: 5 additions & 3 deletions tests/testsuite/rustdocflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ fn whitespace() {
.with_status(101)
.run();

const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d";
p.cargo("doc")
.env_remove("__CARGO_TEST_FORCE_ARGFILE") // Not applicable for argfile.
.env(
"RUSTDOCFLAGS",
format!("--crate-version {}", SPACED_VERSION),
"--crate-version 1111\n2222\t3333\u{00a0}4444",
)
.run();

let contents = p.read_file("target/doc/foo/index.html");
assert!(contents.contains(SPACED_VERSION));
assert!(contents.contains("1111"));
assert!(contents.contains("2222"));
assert!(contents.contains("3333"));
assert!(contents.contains("4444"));
}

#[cargo_test]
Expand Down

0 comments on commit e4fe8f0

Please sign in to comment.