Skip to content

Commit 29548f6

Browse files
committed
Fix failing tests
Signed-off-by: Thomas Lam <thomaslam@canva.com>
1 parent c54a500 commit 29548f6

1 file changed

Lines changed: 10 additions & 50 deletions

File tree

crate_universe/src/rendering.rs

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,8 +2044,10 @@ mod test {
20442044
assert!(found);
20452045
}
20462046

2047-
/// Tests a situation where we identical aliases to the crate's name on the
2048-
/// package's deps
2047+
/// Tests a situation where we have identical aliases to the crate's name on
2048+
/// the package's deps, and the dep is itself a workspace member. Because
2049+
/// workspace-member deps have no spoke repo and no override_targets["lib"]
2050+
/// is set, no hub alias should be emitted at all.
20492051
#[test]
20502052
fn crate_with_ambiguous_rename() {
20512053
let mut context = Context::default();
@@ -2095,54 +2097,12 @@ mod test {
20952097
let build_file_content = output.get(&PathBuf::from("BUILD.bazel")).unwrap();
20962098

20972099
println!("{build_file_content}");
2098-
let expected = indoc! {r#"
2099-
###############################################################################
2100-
# @generated
2101-
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
2102-
# regenerate this file, run the following:
2103-
#
2104-
# cargo_bazel_regen_command
2105-
###############################################################################
2106-
2107-
package(default_visibility = ["//visibility:public"])
2108-
2109-
exports_files(
2110-
[
2111-
"cargo-bazel.json",
2112-
"defs.bzl",
2113-
] + glob(
2114-
allow_empty = True,
2115-
include = ["*.bazel"],
2116-
),
2117-
)
2118-
2119-
filegroup(
2120-
name = "srcs",
2121-
srcs = glob(
2122-
allow_empty = True,
2123-
include = [
2124-
"*.bazel",
2125-
"*.bzl",
2126-
],
2127-
),
2128-
)
2129-
2130-
# Workspace Member Dependencies
2131-
alias(
2132-
name = "mock_crate-0.1.0",
2133-
actual = "@test_rendering__mock_crate-0.1.0//:library_name",
2134-
tags = ["manual"],
2135-
)
2136-
2137-
alias(
2138-
name = "mock_crate",
2139-
actual = "@test_rendering__mock_crate-0.1.0//:library_name",
2140-
tags = ["manual"],
2141-
)
2142-
"#};
2143-
assert!(build_file_content
2144-
.replace(' ', "")
2145-
.contains(&expected.replace(' ', "")));
2100+
// mock_crate is a workspace member dep with no override_targets["lib"],
2101+
// so no hub alias should be emitted to avoid dangling spoke-repo refs.
2102+
assert!(
2103+
!build_file_content.contains("alias("),
2104+
"no alias should be emitted for workspace member dep with ambiguous rename and no override:\n{build_file_content}"
2105+
);
21462106
}
21472107

21482108
/// Tests a situation where there are two dependencies referencing the same

0 commit comments

Comments
 (0)