Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions src/cargo/ops/cargo_package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,22 +1032,33 @@ impl<'a> TmpRegistry<'a> {
let deps: Vec<_> = new_crate
.deps
.into_iter()
.map(|dep| RegistryDependency {
name: dep.name.into(),
req: dep.version_req.into(),
features: dep.features.into_iter().map(|x| x.into()).collect(),
optional: dep.optional,
default_features: dep.default_features,
target: dep.target.map(|x| x.into()),
kind: Some(dep.kind.into()),
registry: dep.registry.map(|x| x.into()),
package: None,
public: None,
artifact: dep
.artifact
.map(|xs| xs.into_iter().map(|x| x.into()).collect()),
bindep_target: dep.bindep_target.map(|x| x.into()),
lib: dep.lib,
.map(|dep| {
let name = dep
.explicit_name_in_toml
.clone()
.unwrap_or_else(|| dep.name.clone())
.into();
let package = dep
.explicit_name_in_toml
.as_ref()
.map(|_| dep.name.clone().into());
RegistryDependency {
name: name,
req: dep.version_req.into(),
features: dep.features.into_iter().map(|x| x.into()).collect(),
optional: dep.optional,
default_features: dep.default_features,
target: dep.target.map(|x| x.into()),
kind: Some(dep.kind.into()),
registry: dep.registry.map(|x| x.into()),
package: package,
public: None,
artifact: dep
.artifact
.map(|xs| xs.into_iter().map(|x| x.into()).collect()),
bindep_target: dep.bindep_target.map(|x| x.into()),
lib: dep.lib,
}
})
.collect();

Expand Down
104 changes: 104 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6492,6 +6492,110 @@ fn workspace_with_capitalized_member() {
.run();
}

#[cargo_test]
fn workspace_with_renamed_member() {
let reg = registry::init();

let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["crates/*"]
"#,
)
.file(
"crates/val-json/Cargo.toml",
r#"
[package]
name = "obeli-sk-val-json"
version = "0.16.2"
edition = "2015"
authors = []
license = "MIT"
description = "main"
repository = "bar"

[dependencies]
"#,
)
.file("crates/val-json/src/lib.rs", "pub fn foo() {}")
.file(
"crates/concepts/Cargo.toml",
r#"
[package]
name = "obeli-sk-concepts"
version = "0.16.2"
edition = "2015"
authors = []
license = "MIT"
description = "main"
repository = "bar"

[dependencies]
val-json = { package = "obeli-sk-val-json", path = "../val-json", version = "0.16.2" }
"#,
)
.file(
"crates/concepts/src/lib.rs",
"pub fn foo() { val_json::foo() }",
)
.file(
"crates/utils/Cargo.toml",
r#"
[package]
name = "obeli-sk-utils"
version = "0.16.2"
edition = "2015"
authors = []
license = "MIT"
description = "main"
repository = "bar"

[dependencies]
concepts = { package = "obeli-sk-concepts", path = "../concepts", version = "0.16.2" }
val-json = { package = "obeli-sk-val-json", path = "../val-json", version = "0.16.2" }
"#,
)
.file(
"crates/utils/src/lib.rs",
"pub fn foo() { val_json::foo(); concepts::foo(); }",
)
.build();

p.cargo("package -Zpackage-workspace")
.masquerade_as_nightly_cargo(&["package-workspace"])
.replace_crates_io(reg.index_url())
.with_stderr_data(
str![[r#"
[UPDATING] crates.io index
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[PACKAGING] obeli-sk-val-json v0.16.2 ([ROOT]/foo/crates/val-json)
[PACKAGING] obeli-sk-concepts v0.16.2 ([ROOT]/foo/crates/concepts)
[PACKAGING] obeli-sk-utils v0.16.2 ([ROOT]/foo/crates/utils)
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[VERIFYING] obeli-sk-val-json v0.16.2 ([ROOT]/foo/crates/val-json)
[COMPILING] obeli-sk-val-json v0.16.2 ([ROOT]/foo/target/package/obeli-sk-val-json-0.16.2)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[VERIFYING] obeli-sk-concepts v0.16.2 ([ROOT]/foo/crates/concepts)
[UNPACKING] obeli-sk-val-json v0.16.2 (registry `[ROOT]/foo/target/package/tmp-registry`)
[COMPILING] obeli-sk-val-json v0.16.2
[COMPILING] obeli-sk-concepts v0.16.2 ([ROOT]/foo/target/package/obeli-sk-concepts-0.16.2)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[VERIFYING] obeli-sk-utils v0.16.2 ([ROOT]/foo/crates/utils)
[UNPACKING] obeli-sk-concepts v0.16.2 (registry `[ROOT]/foo/target/package/tmp-registry`)
[COMPILING] obeli-sk-val-json v0.16.2
[COMPILING] obeli-sk-concepts v0.16.2
[COMPILING] obeli-sk-utils v0.16.2 ([ROOT]/foo/target/package/obeli-sk-utils-0.16.2)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]]
.unordered(),
)
.run();
}

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