Skip to content

Commit a0ad67a

Browse files
committed
test(publish): show no idempotent workspace publish
1 parent c36dd1c commit a0ad67a

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
@@ -4367,6 +4367,101 @@ fn all_unpublishable_packages() {
43674367
.run();
43684368
}
43694369

4370+
#[cargo_test]
4371+
fn all_published_packages() {
4372+
let registry = RegistryBuilder::new().http_api().http_index().build();
4373+
4374+
let p = project()
4375+
.file(
4376+
"Cargo.toml",
4377+
r#"
4378+
[workspace]
4379+
members = ["foo", "bar"]
4380+
"#,
4381+
)
4382+
.file(
4383+
"foo/Cargo.toml",
4384+
r#"
4385+
[package]
4386+
name = "foo"
4387+
version = "0.0.0"
4388+
edition = "2015"
4389+
license = "MIT"
4390+
description = "foo"
4391+
repository = "foo"
4392+
"#,
4393+
)
4394+
.file("foo/src/lib.rs", "")
4395+
.file(
4396+
"bar/Cargo.toml",
4397+
r#"
4398+
[package]
4399+
name = "bar"
4400+
version = "0.0.0"
4401+
edition = "2015"
4402+
license = "MIT"
4403+
description = "foo"
4404+
repository = "foo"
4405+
"#,
4406+
)
4407+
.file("bar/src/lib.rs", "")
4408+
.build();
4409+
4410+
// First, publish all members
4411+
p.cargo("publish --workspace --no-verify")
4412+
.replace_crates_io(registry.index_url())
4413+
.with_stderr_data(str![[r#"
4414+
[UPDATING] crates.io index
4415+
[PACKAGING] bar v0.0.0 ([ROOT]/foo/bar)
4416+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4417+
[PACKAGING] foo v0.0.0 ([ROOT]/foo/foo)
4418+
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4419+
[UPLOADING] bar v0.0.0 ([ROOT]/foo/bar)
4420+
[UPLOADED] bar v0.0.0 to registry `crates-io`
4421+
[UPLOADING] foo v0.0.0 ([ROOT]/foo/foo)
4422+
[UPLOADED] foo v0.0.0 to registry `crates-io`
4423+
[NOTE] waiting for bar v0.0.0 or foo v0.0.0 to be available at registry `crates-io`
4424+
[HELP] you may press ctrl-c to skip waiting; the crates should be available shortly
4425+
[PUBLISHED] bar v0.0.0 and foo v0.0.0 at registry `crates-io`
4426+
4427+
"#]])
4428+
.run();
4429+
4430+
// Publishing all members again works
4431+
p.cargo("publish --workspace --no-verify")
4432+
.replace_crates_io(registry.index_url())
4433+
.with_status(101)
4434+
.with_stderr_data(str![[r#"
4435+
[UPDATING] crates.io index
4436+
[ERROR] crate [email protected] already exists on crates.io index
4437+
4438+
"#]])
4439+
.run();
4440+
4441+
// Without `--workspace` works as it is a virtual workspace
4442+
p.cargo("publish --no-verify")
4443+
.replace_crates_io(registry.index_url())
4444+
.with_status(101)
4445+
.with_stderr_data(str![[r#"
4446+
[UPDATING] crates.io index
4447+
[ERROR] crate [email protected] already exists on crates.io index
4448+
4449+
"#]])
4450+
.run();
4451+
4452+
// Change a file. It should fail due to checksum verification failure.
4453+
p.change_file("bar/src/lib.rs", "//! foo");
4454+
p.cargo("publish --no-verify")
4455+
.replace_crates_io(registry.index_url())
4456+
.with_status(101)
4457+
.with_stderr_data(str![[r#"
4458+
[UPDATING] crates.io index
4459+
[ERROR] crate [email protected] already exists on crates.io index
4460+
4461+
"#]])
4462+
.run();
4463+
}
4464+
43704465
#[cargo_test]
43714466
fn checksum_changed() {
43724467
let registry = RegistryBuilder::new().http_api().http_index().build();

0 commit comments

Comments
 (0)