Skip to content

Commit 8f9ac58

Browse files
committed
test(publish): show no idempotent workspace publish
1 parent dd9e312 commit 8f9ac58

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

tests/testsuite/publish.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,6 +4328,101 @@ fn all_unpublishable_packages() {
43284328
.run();
43294329
}
43304330

4331+
#[cargo_test]
4332+
fn all_published_packages() {
4333+
let registry = RegistryBuilder::new().http_api().http_index().build();
4334+
4335+
let p = project()
4336+
.file(
4337+
"Cargo.toml",
4338+
r#"
4339+
[workspace]
4340+
members = ["foo", "bar"]
4341+
"#,
4342+
)
4343+
.file(
4344+
"foo/Cargo.toml",
4345+
r#"
4346+
[package]
4347+
name = "foo"
4348+
version = "0.0.0"
4349+
edition = "2015"
4350+
license = "MIT"
4351+
description = "foo"
4352+
repository = "foo"
4353+
"#,
4354+
)
4355+
.file("foo/src/lib.rs", "")
4356+
.file(
4357+
"bar/Cargo.toml",
4358+
r#"
4359+
[package]
4360+
name = "bar"
4361+
version = "0.0.0"
4362+
edition = "2015"
4363+
license = "MIT"
4364+
description = "foo"
4365+
repository = "foo"
4366+
"#,
4367+
)
4368+
.file("bar/src/lib.rs", "")
4369+
.build();
4370+
4371+
// First, publish all members
4372+
p.cargo("publish --workspace --no-verify")
4373+
.replace_crates_io(registry.index_url())
4374+
.with_stderr_data(str![[r#"
4375+
[UPDATING] crates.io index
4376+
[PACKAGING] bar v0.0.0 ([ROOT]/foo/bar)
4377+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4378+
[PACKAGING] foo v0.0.0 ([ROOT]/foo/foo)
4379+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4380+
[UPLOADING] bar v0.0.0 ([ROOT]/foo/bar)
4381+
[UPLOADED] bar v0.0.0 to registry `crates-io`
4382+
[UPLOADING] foo v0.0.0 ([ROOT]/foo/foo)
4383+
[UPLOADED] foo v0.0.0 to registry `crates-io`
4384+
[NOTE] waiting for bar v0.0.0 or foo v0.0.0 to be available at registry `crates-io`
4385+
[HELP] you may press ctrl-c to skip waiting; the crates should be available shortly
4386+
[PUBLISHED] bar v0.0.0 and foo v0.0.0 at registry `crates-io`
4387+
4388+
"#]])
4389+
.run();
4390+
4391+
// Publishing all members again works
4392+
p.cargo("publish --workspace --no-verify")
4393+
.replace_crates_io(registry.index_url())
4394+
.with_status(101)
4395+
.with_stderr_data(str![[r#"
4396+
[UPDATING] crates.io index
4397+
[ERROR] crate [email protected] already exists on crates.io index
4398+
4399+
"#]])
4400+
.run();
4401+
4402+
// Without `--workspace` works as it is a virtual workspace
4403+
p.cargo("publish --no-verify")
4404+
.replace_crates_io(registry.index_url())
4405+
.with_status(101)
4406+
.with_stderr_data(str![[r#"
4407+
[UPDATING] crates.io index
4408+
[ERROR] crate [email protected] already exists on crates.io index
4409+
4410+
"#]])
4411+
.run();
4412+
4413+
// Change a file. It should fail due to checksum verification failure.
4414+
p.change_file("bar/src/lib.rs", "//! foo");
4415+
p.cargo("publish --no-verify")
4416+
.replace_crates_io(registry.index_url())
4417+
.with_status(101)
4418+
.with_stderr_data(str![[r#"
4419+
[UPDATING] crates.io index
4420+
[ERROR] crate [email protected] already exists on crates.io index
4421+
4422+
"#]])
4423+
.run();
4424+
}
4425+
43314426
#[cargo_test]
43324427
fn checksum_changed() {
43334428
let registry = RegistryBuilder::new().http_api().http_index().build();

0 commit comments

Comments
 (0)