@@ -4351,6 +4351,38 @@ fn all_unpublishable_packages() {
4351
4351
#[ cargo_test]
4352
4352
fn workspace_publish_failure_reports_remaining_packages ( ) {
4353
4353
use cargo_test_support:: project;
4354
+ use cargo_test_support:: registry:: RegistryBuilder ;
4355
+
4356
+ // Create a registry that will fail for package 'a' but succeed for others
4357
+ let _registry = RegistryBuilder :: new ( )
4358
+ . alternative ( )
4359
+ . http_api ( )
4360
+ . add_responder ( "/api/v1/crates/new" , |req, _| {
4361
+ if let Some ( body) = & req. body {
4362
+ let body_str = String :: from_utf8_lossy ( body) ;
4363
+ if body_str. contains ( "\" name\" :\" a\" " ) {
4364
+ Response {
4365
+ body : b"{\" errors\" :[{\" detail\" :\" crate [email protected] already exists on crates.io index\" }]}" . to_vec ( ) ,
4366
+ code : 400 ,
4367
+ headers : vec ! [ "Content-Type: application/json" . to_string( ) ] ,
4368
+ }
4369
+ } else {
4370
+ Response {
4371
+ body : b"{\" ok\" :true}" . to_vec ( ) ,
4372
+ code : 200 ,
4373
+ headers : vec ! [ "Content-Type: application/json" . to_string( ) ] ,
4374
+ }
4375
+ }
4376
+ } else {
4377
+ Response {
4378
+ body : b"{\" ok\" :true}" . to_vec ( ) ,
4379
+ code : 200 ,
4380
+ headers : vec ! [ "Content-Type: application/json" . to_string( ) ] ,
4381
+ }
4382
+ }
4383
+ } )
4384
+ . build ( ) ;
4385
+
4354
4386
let p = project ( )
4355
4387
. file (
4356
4388
"Cargo.toml" ,
@@ -4366,6 +4398,9 @@ fn workspace_publish_failure_reports_remaining_packages() {
4366
4398
name = "a"
4367
4399
version = "0.1.0"
4368
4400
edition = "2021"
4401
+ authors = []
4402
+ license = "MIT"
4403
+ description = "Package A"
4369
4404
"# ,
4370
4405
)
4371
4406
. file ( "a/src/lib.rs" , "" )
@@ -4376,6 +4411,9 @@ fn workspace_publish_failure_reports_remaining_packages() {
4376
4411
name = "b"
4377
4412
version = "0.1.0"
4378
4413
edition = "2021"
4414
+ authors = []
4415
+ license = "MIT"
4416
+ description = "Package B"
4379
4417
"# ,
4380
4418
)
4381
4419
. file ( "b/src/lib.rs" , "" )
@@ -4386,17 +4424,55 @@ fn workspace_publish_failure_reports_remaining_packages() {
4386
4424
name = "c"
4387
4425
version = "0.1.0"
4388
4426
edition = "2021"
4427
+ authors = []
4428
+ license = "MIT"
4429
+ description = "Package C"
4389
4430
"# ,
4390
4431
)
4391
4432
. file ( "c/src/lib.rs" , "" )
4392
4433
. build ( ) ;
4393
4434
4394
- // Simulate a publish failure for package 'a' (e.g., already published)
4395
- // The error message should match the actual output from the verify step
4396
- p. cargo ( "publish --workspace" )
4397
- . env ( "CARGO_REGISTRY_TOKEN" , "dummy-token" )
4435
+ // Test that when package 'a' fails to publish, the error message includes
4436
+ // information about which packages remain unpublished
4437
+ p. cargo ( "publish --workspace --registry alternative" )
4398
4438
. with_status ( 101 )
4399
- . with_stderr_contains ( "[ERROR] crate [email protected] already exists on crates.io index" )
4439
+ . with_stderr_data ( str![ [ r#"
4440
+ [WARNING] virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
4441
+ [NOTE] to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
4442
+ [NOTE] to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
4443
+ [NOTE] for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
4444
+ [UPDATING] `alternative` index
4445
+ [WARNING] manifest has no documentation, homepage or repository.
4446
+ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
4447
+ [PACKAGING] a v0.1.0 ([ROOT]/foo/a)
4448
+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4449
+ [WARNING] manifest has no documentation, homepage or repository.
4450
+ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
4451
+ [PACKAGING] b v0.1.0 ([ROOT]/foo/b)
4452
+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4453
+ [WARNING] manifest has no documentation, homepage or repository.
4454
+ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
4455
+ [PACKAGING] c v0.1.0 ([ROOT]/foo/c)
4456
+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4457
+ [VERIFYING] a v0.1.0 ([ROOT]/foo/a)
4458
+ [COMPILING] a v0.1.0 ([ROOT]/foo/target/package/a-0.1.0)
4459
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
4460
+ [VERIFYING] b v0.1.0 ([ROOT]/foo/b)
4461
+ [COMPILING] b v0.1.0 ([ROOT]/foo/target/package/b-0.1.0)
4462
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
4463
+ [VERIFYING] c v0.1.0 ([ROOT]/foo/c)
4464
+ [COMPILING] c v0.1.0 ([ROOT]/foo/target/package/c-0.1.0)
4465
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
4466
+ [UPLOADING] a v0.1.0 ([ROOT]/foo/a)
4467
+ [ERROR] failed to publish `a` v0.1.0; the following crates have not been published yet: b v0.1.0, c v0.1.0
4468
+
4469
+ Caused by:
4470
+ failed to publish to registry at http://127.0.0.1:[..]/
4471
+
4472
+ Caused by:
4473
+ the remote server responded with an error (status 400 Bad Request): crate [email protected] already exists on crates.io index
4474
+
4475
+ "# ] ] )
4400
4476
. run ( ) ;
4401
4477
}
4402
4478
0 commit comments