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
5 changes: 2 additions & 3 deletions src/cargo/ops/registry/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
// upload.
let mut ready = plan.take_ready();

if ready.is_empty() {
// Circular dependencies are caught above, so this indicates a failure
// to progress, potentially due to a timeout while waiting for confirmations.
if ready.is_empty() && to_confirm.is_empty() {
// Cycles are caught above; reaching here means an unexpected stall.
return Err(crate::util::internal(format!(
"no packages ready to publish but {} packages remain in plan with {} awaiting confirmation: {}",
plan.len(),
Expand Down
106 changes: 106 additions & 0 deletions tests/testsuite/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3409,6 +3409,112 @@ fn timeout_waiting_for_publish() {
.run();
}

#[cargo_test]
fn wait_for_workspace_publish() {
let arc: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));

let registry = registry::RegistryBuilder::new()
.http_api()
.http_index()
.add_responder("/index/1/c", move |req, server| {
let mut lock = arc.lock().unwrap();
*lock += 1;
// 3 queries come from resolving `c` during packaging of `a`
// 3 more from the wait loop while `b` and `c` are being confirmed
// `c` becomes available on the 7th query, unblocking `a`
if *lock <= 6 {
Comment thread
raushan728 marked this conversation as resolved.
server.not_found(req)
} else {
server.index(req)
}
})
.build();

let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["a", "b", "c"]
"#,
)
.file(
"a/Cargo.toml",
r#"
[package]
name = "a"
version = "1.0.0"
edition = "2015"
license = "MIT"
description = "a"
repository = "a"

[dependencies]
b = { version = "1.0", path = "../b" }
c = { version = "1.0", path = "../c" }
"#,
)
.file("a/src/lib.rs", "")
.file(
"b/Cargo.toml",
r#"
[package]
name = "b"
version = "1.0.0"
edition = "2015"
license = "MIT"
description = "b"
repository = "b"
"#,
)
.file("b/src/lib.rs", "")
.file(
"c/Cargo.toml",
r#"
[package]
name = "c"
version = "1.0.0"
edition = "2015"
license = "MIT"
description = "c"
repository = "c"
"#,
)
.file("c/src/lib.rs", "")
.build();

p.cargo("publish --workspace --no-verify")
.replace_crates_io(registry.index_url())
.with_status(0)
.with_stderr_data(str![[r#"
[UPDATING] crates.io index
[PACKAGING] b v1.0.0 ([ROOT]/foo/b)
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[PACKAGING] c v1.0.0 ([ROOT]/foo/c)
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[PACKAGING] a v1.0.0 ([ROOT]/foo/a)
[UPDATING] crates.io index
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[UPLOADING] b v1.0.0 ([ROOT]/foo/b)
[UPLOADED] b v1.0.0 to registry `crates-io`
[UPLOADING] c v1.0.0 ([ROOT]/foo/c)
[UPLOADED] c v1.0.0 to registry `crates-io`
[NOTE] waiting for b v1.0.0 or c v1.0.0 to be available at registry `crates-io`.
1 remaining crate to be published
[PUBLISHED] b v1.0.0 at registry `crates-io`
[NOTE] waiting for c v1.0.0 to be available at registry `crates-io`.
1 remaining crate to be published
[PUBLISHED] c v1.0.0 at registry `crates-io`
[UPLOADING] a v1.0.0 ([ROOT]/foo/a)
[UPLOADED] a v1.0.0 to registry `crates-io`
[NOTE] waiting for a v1.0.0 to be available at registry `crates-io`
[HELP] you may press ctrl-c to skip waiting; the crate should be available shortly
[PUBLISHED] a v1.0.0 at registry `crates-io`

"#]])
.run();
}

#[cargo_test]
fn timeout_waiting_for_dependency_publish() {
// Publish doesn't happen within the timeout window.
Expand Down
Loading