@@ -6173,6 +6173,77 @@ The registry `alternative` is not listed in the `package.publish` value in Cargo
6173
6173
. run ( ) ;
6174
6174
}
6175
6175
6176
+ #[ cargo_test]
6177
+ fn registry_inference_ignores_unpublishable ( ) {
6178
+ let _alt_reg = registry:: RegistryBuilder :: new ( )
6179
+ . http_api ( )
6180
+ . http_index ( )
6181
+ . alternative ( )
6182
+ . build ( ) ;
6183
+
6184
+ let p = project ( )
6185
+ . file (
6186
+ "Cargo.toml" ,
6187
+ r#"
6188
+ [workspace]
6189
+ members = ["dep", "main"]
6190
+ "# ,
6191
+ )
6192
+ . file (
6193
+ "main/Cargo.toml" ,
6194
+ r#"
6195
+ [package]
6196
+ name = "main"
6197
+ version = "0.0.1"
6198
+ edition = "2015"
6199
+ authors = []
6200
+ license = "MIT"
6201
+ description = "main"
6202
+ repository = "bar"
6203
+ publish = false
6204
+
6205
+ [dependencies]
6206
+ dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6207
+ "# ,
6208
+ )
6209
+ . file ( "main/src/main.rs" , "fn main() {}" )
6210
+ . file (
6211
+ "dep/Cargo.toml" ,
6212
+ r#"
6213
+ [package]
6214
+ name = "dep"
6215
+ version = "0.1.0"
6216
+ edition = "2015"
6217
+ authors = []
6218
+ license = "MIT"
6219
+ description = "dep"
6220
+ repository = "bar"
6221
+ publish = ["alternative"]
6222
+ "# ,
6223
+ )
6224
+ . file ( "dep/src/lib.rs" , "" )
6225
+ . build ( ) ;
6226
+
6227
+ p. cargo ( "package -Zpackage-workspace" )
6228
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6229
+ . with_status ( 101 )
6230
+ . with_stderr_data ( str![ [ r#"
6231
+ [ERROR] conflicts between `package.publish` fields in the selected packages
6232
+
6233
+ "# ] ] )
6234
+ . run ( ) ;
6235
+
6236
+ p. cargo ( "package -Zpackage-workspace --registry=alternative" )
6237
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6238
+ . with_status ( 101 )
6239
+ . with_stderr_data ( str![ [ r#"
6240
+ [ERROR] `main` cannot be packaged.
6241
+ The registry `alternative` is not listed in the `package.publish` value in Cargo.toml.
6242
+
6243
+ "# ] ] )
6244
+ . run ( ) ;
6245
+ }
6246
+
6176
6247
#[ cargo_test]
6177
6248
fn registry_not_inferred_because_of_multiple_options ( ) {
6178
6249
let _alt_reg = registry:: RegistryBuilder :: new ( )
@@ -6337,3 +6408,63 @@ fn registry_not_inferred_because_of_mismatch() {
6337
6408
"# ] ] )
6338
6409
. run ( ) ;
6339
6410
}
6411
+
6412
+ #[ cargo_test]
6413
+ fn unpublishable_dependency ( ) {
6414
+ let _alt_reg = registry:: RegistryBuilder :: new ( )
6415
+ . http_api ( )
6416
+ . http_index ( )
6417
+ . alternative ( )
6418
+ . build ( ) ;
6419
+
6420
+ let p = project ( )
6421
+ . file (
6422
+ "Cargo.toml" ,
6423
+ r#"
6424
+ [workspace]
6425
+ members = ["dep", "main"]
6426
+ "# ,
6427
+ )
6428
+ . file (
6429
+ "main/Cargo.toml" ,
6430
+ r#"
6431
+ [package]
6432
+ name = "main"
6433
+ version = "0.0.1"
6434
+ edition = "2015"
6435
+ authors = []
6436
+ license = "MIT"
6437
+ description = "main"
6438
+ repository = "bar"
6439
+
6440
+ [dependencies]
6441
+ dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6442
+ "# ,
6443
+ )
6444
+ . file ( "main/src/main.rs" , "fn main() {}" )
6445
+ . file (
6446
+ "dep/Cargo.toml" ,
6447
+ r#"
6448
+ [package]
6449
+ name = "dep"
6450
+ version = "0.1.0"
6451
+ edition = "2015"
6452
+ authors = []
6453
+ license = "MIT"
6454
+ description = "dep"
6455
+ repository = "bar"
6456
+ publish = false
6457
+ "# ,
6458
+ )
6459
+ . file ( "dep/src/lib.rs" , "" )
6460
+ . build ( ) ;
6461
+
6462
+ p. cargo ( "package -Zpackage-workspace" )
6463
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6464
+ . with_status ( 101 )
6465
+ . with_stderr_data ( str![ [ r#"
6466
+ [ERROR] conflicts between `package.publish` fields in the selected packages
6467
+
6468
+ "# ] ] )
6469
+ . run ( ) ;
6470
+ }
0 commit comments