Skip to content

Commit

Permalink
Add test for doc lib/bin collision with a dash.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Mar 25, 2024
1 parent bc844af commit 9e7d6e3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/testsuite/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,42 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() {
assert!(!doc_html.contains("Binary"));
}

#[cargo_test]
fn doc_lib_bin_same_name_with_dash() {
// Checks `doc` behavior when there is a dash in the package name, and
// there is a lib and bin, and the lib name is inferred.
let p = project()
.file("Cargo.toml", &basic_manifest("foo-bar", "1.0.0"))
.file("src/lib.rs", "")
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("doc")
.with_stderr_unordered(
"\
warning: output filename collision.
The bin target `foo-bar` in package `foo-bar v1.0.0 ([ROOT]/foo)` has the same \
output filename as the lib target `foo_bar` in package `foo-bar v1.0.0 ([ROOT]/foo)`.
Colliding filename is: [ROOT]/foo/target/doc/foo_bar/index.html
The output filenames should be unique.
This is a known bug where multiple crates with the same name use
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
If this looks unexpected, it may be a bug in Cargo. Please file a bug report at
https://github.com/rust-lang/cargo/issues/ with as much information as you
can provide.
cargo [..]
First unit: [..]
Second unit: [..]
[CHECKING] foo-bar v1.0.0 ([ROOT]/foo)
[DOCUMENTING] foo-bar v1.0.0 ([ROOT]/foo)
[FINISHED] [..]
[GENERATED] [ROOT]/foo/target/doc/foo_bar/index.html and 1 other file
",
)
.run();
assert!(p.build_dir().join("doc/foo_bar/index.html").exists());
assert!(p.build_dir().join("doc/foo_bar/fn.main.html").exists());
}

#[cargo_test]
fn doc_lib_bin_same_name_documents_named_bin_when_requested() {
let p = project()
Expand Down

0 comments on commit 9e7d6e3

Please sign in to comment.