Skip to content

Commit 68f0c65

Browse files
committed
test(package): Show stable behavior for -Zpackage-workspace
1 parent d6cc0fb commit 68f0c65

File tree

1 file changed

+208
-0
lines changed

1 file changed

+208
-0
lines changed

tests/testsuite/package.rs

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6885,6 +6885,75 @@ fn registry_inferred_from_unique_option() {
68856885
.run();
68866886
}
68876887

6888+
#[cargo_test]
6889+
fn registry_not_inferred_because_of_conflict() {
6890+
let _alt_reg = registry::RegistryBuilder::new()
6891+
.http_api()
6892+
.http_index()
6893+
.alternative()
6894+
.build();
6895+
6896+
let p = project()
6897+
.file(
6898+
"Cargo.toml",
6899+
r#"
6900+
[workspace]
6901+
members = ["dep", "main"]
6902+
"#,
6903+
)
6904+
.file(
6905+
"main/Cargo.toml",
6906+
r#"
6907+
[package]
6908+
name = "main"
6909+
version = "0.0.1"
6910+
edition = "2015"
6911+
authors = []
6912+
license = "MIT"
6913+
description = "main"
6914+
repository = "bar"
6915+
publish = ["alternative"]
6916+
6917+
[dependencies]
6918+
dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6919+
"#,
6920+
)
6921+
.file("main/src/main.rs", "fn main() {}")
6922+
.file(
6923+
"dep/Cargo.toml",
6924+
r#"
6925+
[package]
6926+
name = "dep"
6927+
version = "0.1.0"
6928+
edition = "2015"
6929+
authors = []
6930+
license = "MIT"
6931+
description = "dep"
6932+
repository = "bar"
6933+
publish = ["alternative2"]
6934+
"#,
6935+
)
6936+
.file("dep/src/lib.rs", "")
6937+
.build();
6938+
6939+
p.cargo("package")
6940+
.with_status(101)
6941+
.with_stderr_data(str![[r#"
6942+
[PACKAGING] dep v0.1.0 ([ROOT]/foo/dep)
6943+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6944+
[PACKAGING] main v0.0.1 ([ROOT]/foo/main)
6945+
[UPDATING] `alternative` index
6946+
[ERROR] failed to prepare local package for uploading
6947+
6948+
Caused by:
6949+
no matching package named `dep` found
6950+
location searched: `alternative` index
6951+
required by package `main v0.0.1 ([ROOT]/foo/main)`
6952+
6953+
"#]])
6954+
.run();
6955+
}
6956+
68886957
#[cargo_test]
68896958
fn registry_not_inferred_because_of_conflict_nightly() {
68906959
let alt_reg = registry::RegistryBuilder::new()
@@ -7073,6 +7142,75 @@ fn registry_inference_ignores_unpublishable() {
70737142
.run();
70747143
}
70757144

7145+
#[cargo_test]
7146+
fn registry_not_inferred_because_of_multiple_options() {
7147+
let _alt_reg = registry::RegistryBuilder::new()
7148+
.http_api()
7149+
.http_index()
7150+
.alternative()
7151+
.build();
7152+
7153+
let p = project()
7154+
.file(
7155+
"Cargo.toml",
7156+
r#"
7157+
[workspace]
7158+
members = ["dep", "main"]
7159+
"#,
7160+
)
7161+
.file(
7162+
"main/Cargo.toml",
7163+
r#"
7164+
[package]
7165+
name = "main"
7166+
version = "0.0.1"
7167+
edition = "2015"
7168+
authors = []
7169+
license = "MIT"
7170+
description = "main"
7171+
repository = "bar"
7172+
publish = ["alternative", "alternative2"]
7173+
7174+
[dependencies]
7175+
dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
7176+
"#,
7177+
)
7178+
.file("main/src/main.rs", "fn main() {}")
7179+
.file(
7180+
"dep/Cargo.toml",
7181+
r#"
7182+
[package]
7183+
name = "dep"
7184+
version = "0.1.0"
7185+
edition = "2015"
7186+
authors = []
7187+
license = "MIT"
7188+
description = "dep"
7189+
repository = "bar"
7190+
publish = ["alternative", "alternative2"]
7191+
"#,
7192+
)
7193+
.file("dep/src/lib.rs", "")
7194+
.build();
7195+
7196+
p.cargo("package")
7197+
.with_status(101)
7198+
.with_stderr_data(str![[r#"
7199+
[PACKAGING] dep v0.1.0 ([ROOT]/foo/dep)
7200+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
7201+
[PACKAGING] main v0.0.1 ([ROOT]/foo/main)
7202+
[UPDATING] `alternative` index
7203+
[ERROR] failed to prepare local package for uploading
7204+
7205+
Caused by:
7206+
no matching package named `dep` found
7207+
location searched: `alternative` index
7208+
required by package `main v0.0.1 ([ROOT]/foo/main)`
7209+
7210+
"#]])
7211+
.run();
7212+
}
7213+
70767214
#[cargo_test]
70777215
fn registry_not_inferred_because_of_multiple_options_nightly() {
70787216
let _alt_reg = registry::RegistryBuilder::new()
@@ -7155,6 +7293,76 @@ fn registry_not_inferred_because_of_multiple_options_nightly() {
71557293
.run();
71567294
}
71577295

7296+
#[cargo_test]
7297+
fn registry_not_inferred_because_of_mismatch() {
7298+
let _alt_reg = registry::RegistryBuilder::new()
7299+
.http_api()
7300+
.http_index()
7301+
.alternative()
7302+
.build();
7303+
7304+
let p = project()
7305+
.file(
7306+
"Cargo.toml",
7307+
r#"
7308+
[workspace]
7309+
members = ["dep", "main"]
7310+
"#,
7311+
)
7312+
.file(
7313+
"main/Cargo.toml",
7314+
r#"
7315+
[package]
7316+
name = "main"
7317+
version = "0.0.1"
7318+
edition = "2015"
7319+
authors = []
7320+
license = "MIT"
7321+
description = "main"
7322+
repository = "bar"
7323+
publish = ["alternative"]
7324+
7325+
[dependencies]
7326+
dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
7327+
"#,
7328+
)
7329+
.file("main/src/main.rs", "fn main() {}")
7330+
// No `publish` field means "any registry", but the presence of this package
7331+
// will stop us from inferring a registry.
7332+
.file(
7333+
"dep/Cargo.toml",
7334+
r#"
7335+
[package]
7336+
name = "dep"
7337+
version = "0.1.0"
7338+
edition = "2015"
7339+
authors = []
7340+
license = "MIT"
7341+
description = "dep"
7342+
repository = "bar"
7343+
"#,
7344+
)
7345+
.file("dep/src/lib.rs", "")
7346+
.build();
7347+
7348+
p.cargo("package")
7349+
.with_status(101)
7350+
.with_stderr_data(str![[r#"
7351+
[PACKAGING] dep v0.1.0 ([ROOT]/foo/dep)
7352+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
7353+
[PACKAGING] main v0.0.1 ([ROOT]/foo/main)
7354+
[UPDATING] `alternative` index
7355+
[ERROR] failed to prepare local package for uploading
7356+
7357+
Caused by:
7358+
no matching package named `dep` found
7359+
location searched: `alternative` index
7360+
required by package `main v0.0.1 ([ROOT]/foo/main)`
7361+
7362+
"#]])
7363+
.run();
7364+
}
7365+
71587366
#[cargo_test]
71597367
fn registry_not_inferred_because_of_mismatch_nightly() {
71607368
let _alt_reg = registry::RegistryBuilder::new()

0 commit comments

Comments
 (0)