Skip to content

Commit 7bc982b

Browse files
committed
test(package): fail with unpublished cyclic/transitive deps
After dd698ff, `cargo package --no-verify` at least fails in three different cases: * An unpublished package depending on itself as a dev-dependency (cyclic self-referential dev-dependencies). * Can be resolved by removing the `version` field from the affected dev-dependency. * `-Zpackage-workspace` doesn't help with it. * Existing `cargo package` has `--package <pkg>` specifying certain unpublished packages. * Can be resolved by specifying all unpublished packages in one `cargo` call. * `-Zpackage-workspace` also requires all dependency versions available in the target registry when calling, so doesn't help. * `cargo package --no-verify` has been used as a kind of “plumbing commands” to create tarballs without considering dependency orders. The use cases include: * Preparing tarballs for other package managers. * Integrating into custom develop workflows for unpublished/internal crates. * Constructing custom/private registries. This commit shows the former two cases.
1 parent 2dcb9b0 commit 7bc982b

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

tests/testsuite/package.rs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7284,3 +7284,93 @@ This might cause the `.crate` file to include incorrect or incomplete files
72847284
],
72857285
);
72867286
}
7287+
7288+
// A failing case from <https://github.com/rust-lang/cargo/issues/15059>
7289+
#[cargo_test]
7290+
fn unpublished_cyclic_dev_dependencies() {
7291+
registry::init();
7292+
let p = project()
7293+
.file(
7294+
"Cargo.toml",
7295+
r#"
7296+
[package]
7297+
name = "foo"
7298+
version = "0.0.1"
7299+
edition = "2015"
7300+
authors = []
7301+
license = "MIT"
7302+
description = "foo"
7303+
documentation = "foo"
7304+
7305+
[dev-dependencies]
7306+
foo = { path = ".", version = "0.0.1" }
7307+
"#,
7308+
)
7309+
.file("src/lib.rs", "")
7310+
.build();
7311+
7312+
p.cargo("package --no-verify")
7313+
.with_status(101)
7314+
.with_stderr_data(str![[r#"
7315+
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
7316+
[UPDATING] `dummy-registry` index
7317+
[ERROR] failed to prepare local package for uploading
7318+
7319+
Caused by:
7320+
no matching package named `foo` found
7321+
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
7322+
required by package `foo v0.0.1 ([ROOT]/foo)`
7323+
7324+
"#]])
7325+
.run();
7326+
}
7327+
7328+
// A failing case from <https://github.com/rust-lang/cargo/issues/15059>
7329+
#[cargo_test]
7330+
fn unpublished_dependency() {
7331+
registry::init();
7332+
let p = project()
7333+
.file(
7334+
"Cargo.toml",
7335+
r#"
7336+
[package]
7337+
name = "foo"
7338+
version = "0.0.1"
7339+
edition = "2015"
7340+
authors = []
7341+
license = "MIT"
7342+
description = "foo"
7343+
documentation = "foo"
7344+
7345+
[dependencies]
7346+
dep = { path = "./dep", version = "0.0.1" }
7347+
"#,
7348+
)
7349+
.file("src/lib.rs", "")
7350+
.file(
7351+
"dep/Cargo.toml",
7352+
r#"
7353+
[package]
7354+
name = "dep"
7355+
version = "0.0.1"
7356+
edition = "2015"
7357+
"#,
7358+
)
7359+
.file("src/lib.rs", "")
7360+
.build();
7361+
7362+
p.cargo("package --no-verify -p foo")
7363+
.with_status(101)
7364+
.with_stderr_data(str![[r#"
7365+
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
7366+
[UPDATING] `dummy-registry` index
7367+
[ERROR] failed to prepare local package for uploading
7368+
7369+
Caused by:
7370+
no matching package named `dep` found
7371+
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
7372+
required by package `foo v0.0.1 ([ROOT]/foo)`
7373+
7374+
"#]])
7375+
.run();
7376+
}

0 commit comments

Comments
 (0)