@@ -5943,3 +5943,364 @@ fn workspace_with_local_and_remote_deps() {
5943
5943
)
5944
5944
. run ( ) ;
5945
5945
}
5946
+
5947
+ #[ cargo_test]
5948
+ fn registry_not_in_publish_list ( ) {
5949
+ let p = project ( )
5950
+ . file (
5951
+ "Cargo.toml" ,
5952
+ r#"
5953
+ [package]
5954
+ name = "foo"
5955
+ version = "0.0.1"
5956
+ edition = "2015"
5957
+ authors = []
5958
+ license = "MIT"
5959
+ description = "foo"
5960
+ publish = [
5961
+ "test"
5962
+ ]
5963
+ "# ,
5964
+ )
5965
+ . file ( "src/main.rs" , "fn main() {}" )
5966
+ . build ( ) ;
5967
+
5968
+ p. cargo ( "package --registry alternative -Zpackage-workspace" )
5969
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
5970
+ . with_status ( 101 )
5971
+ . with_stderr_data ( str![ [ r#"
5972
+ [ERROR] registry index was not found in any configuration: `alternative`
5973
+
5974
+ "# ] ] )
5975
+ . run ( ) ;
5976
+ }
5977
+
5978
+ #[ cargo_test]
5979
+ fn registry_inferred_from_unique_option ( ) {
5980
+ let _registry = registry:: RegistryBuilder :: new ( )
5981
+ . http_api ( )
5982
+ . http_index ( )
5983
+ . alternative ( )
5984
+ . build ( ) ;
5985
+
5986
+ let p = project ( )
5987
+ . file (
5988
+ "Cargo.toml" ,
5989
+ r#"
5990
+ [workspace]
5991
+ members = ["dep", "main"]
5992
+ "# ,
5993
+ )
5994
+ . file (
5995
+ "main/Cargo.toml" ,
5996
+ r#"
5997
+ [package]
5998
+ name = "main"
5999
+ version = "0.0.1"
6000
+ edition = "2015"
6001
+ authors = []
6002
+ license = "MIT"
6003
+ description = "main"
6004
+ repository = "bar"
6005
+ publish = ["alternative"]
6006
+
6007
+ [dependencies]
6008
+ dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6009
+ "# ,
6010
+ )
6011
+ . file ( "main/src/main.rs" , "fn main() {}" )
6012
+ . file (
6013
+ "dep/Cargo.toml" ,
6014
+ r#"
6015
+ [package]
6016
+ name = "dep"
6017
+ version = "0.1.0"
6018
+ edition = "2015"
6019
+ authors = []
6020
+ license = "MIT"
6021
+ description = "dep"
6022
+ repository = "bar"
6023
+ publish = ["alternative"]
6024
+ "# ,
6025
+ )
6026
+ . file ( "dep/src/lib.rs" , "" )
6027
+ . build ( ) ;
6028
+
6029
+ p. cargo ( "package -Zpackage-workspace" )
6030
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6031
+ . with_status ( 101 )
6032
+ . with_stderr_data ( str![ [ r#"
6033
+ [PACKAGING] dep v0.1.0 ([ROOT]/foo/dep)
6034
+ [PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6035
+ [PACKAGING] main v0.0.1 ([ROOT]/foo/main)
6036
+ [UPDATING] `alternative` index
6037
+ [ERROR] failed to prepare local package for uploading
6038
+
6039
+ Caused by:
6040
+ no matching package named `dep` found
6041
+ location searched: registry `alternative`
6042
+ required by package `main v0.0.1 ([ROOT]/foo/main)`
6043
+
6044
+ "# ] ] )
6045
+ . run ( ) ;
6046
+ }
6047
+
6048
+ #[ cargo_test]
6049
+ fn registry_not_inferred_because_of_missing_option ( ) {
6050
+ let alt_reg = registry:: RegistryBuilder :: new ( )
6051
+ . http_api ( )
6052
+ . http_index ( )
6053
+ . alternative ( )
6054
+ . build ( ) ;
6055
+
6056
+ let p = project ( )
6057
+ . file (
6058
+ "Cargo.toml" ,
6059
+ r#"
6060
+ [workspace]
6061
+ members = ["dep", "main"]
6062
+ "# ,
6063
+ )
6064
+ . file (
6065
+ "main/Cargo.toml" ,
6066
+ r#"
6067
+ [package]
6068
+ name = "main"
6069
+ version = "0.0.1"
6070
+ edition = "2015"
6071
+ authors = []
6072
+ license = "MIT"
6073
+ description = "main"
6074
+ repository = "bar"
6075
+ publish = ["alternative"]
6076
+
6077
+ [dependencies]
6078
+ dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6079
+ "# ,
6080
+ )
6081
+ . file ( "main/src/main.rs" , "fn main() {}" )
6082
+ . file (
6083
+ "dep/Cargo.toml" ,
6084
+ r#"
6085
+ [package]
6086
+ name = "dep"
6087
+ version = "0.1.0"
6088
+ edition = "2015"
6089
+ authors = []
6090
+ license = "MIT"
6091
+ description = "dep"
6092
+ repository = "bar"
6093
+ publish = ["alternative2"]
6094
+ "# ,
6095
+ )
6096
+ . file ( "dep/src/lib.rs" , "" )
6097
+ . build ( ) ;
6098
+
6099
+ p. cargo ( "package -Zpackage-workspace" )
6100
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6101
+ . with_status ( 101 )
6102
+ . with_stderr_data ( str![ [ r#"
6103
+ [ERROR] `dep` cannot be packaged.
6104
+ The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml.
6105
+
6106
+ "# ] ] )
6107
+ . run ( ) ;
6108
+
6109
+ p. cargo ( "package -Zpackage-workspace --registry=alternative" )
6110
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6111
+ . with_status ( 101 )
6112
+ . with_stderr_data ( str![ [ r#"
6113
+ [ERROR] `dep` cannot be packaged.
6114
+ The registry `alternative` is not listed in the `package.publish` value in Cargo.toml.
6115
+
6116
+ "# ] ] )
6117
+ . run ( ) ;
6118
+
6119
+ p. cargo ( & format ! (
6120
+ "package --index {} -Zpackage-workspace" ,
6121
+ alt_reg. index_url( )
6122
+ ) )
6123
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6124
+ . with_status ( 101 )
6125
+ . with_stderr_data ( str![ [ r#"
6126
+ [ERROR] `dep` cannot be packaged.
6127
+ The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml.
6128
+
6129
+ "# ] ] )
6130
+ . run ( ) ;
6131
+ }
6132
+
6133
+ #[ cargo_test]
6134
+ fn registry_not_inferred_because_of_multiple_options ( ) {
6135
+ let _alt_reg = registry:: RegistryBuilder :: new ( )
6136
+ . http_api ( )
6137
+ . http_index ( )
6138
+ . alternative ( )
6139
+ . build ( ) ;
6140
+
6141
+ let p = project ( )
6142
+ . file (
6143
+ "Cargo.toml" ,
6144
+ r#"
6145
+ [workspace]
6146
+ members = ["dep", "main", "other"]
6147
+ "# ,
6148
+ )
6149
+ . file (
6150
+ "main/Cargo.toml" ,
6151
+ r#"
6152
+ [package]
6153
+ name = "main"
6154
+ version = "0.0.1"
6155
+ edition = "2015"
6156
+ authors = []
6157
+ license = "MIT"
6158
+ description = "main"
6159
+ repository = "bar"
6160
+ publish = ["alternative", "alternative2"]
6161
+
6162
+ [dependencies]
6163
+ dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6164
+ "# ,
6165
+ )
6166
+ . file ( "main/src/main.rs" , "fn main() {}" )
6167
+ . file (
6168
+ "dep/Cargo.toml" ,
6169
+ r#"
6170
+ [package]
6171
+ name = "dep"
6172
+ version = "0.1.0"
6173
+ edition = "2015"
6174
+ authors = []
6175
+ license = "MIT"
6176
+ description = "dep"
6177
+ repository = "bar"
6178
+ publish = ["alternative", "alternative2"]
6179
+ "# ,
6180
+ )
6181
+ . file ( "dep/src/lib.rs" , "" )
6182
+ // No publish field means "publish anywhere"
6183
+ . file (
6184
+ "other/Cargo.toml" ,
6185
+ r#"
6186
+ [package]
6187
+ name = "other"
6188
+ version = "0.1.0"
6189
+ edition = "2015"
6190
+ authors = []
6191
+ license = "MIT"
6192
+ description = "dep"
6193
+ repository = "bar"
6194
+ "# ,
6195
+ )
6196
+ . file ( "other/src/lib.rs" , "" )
6197
+ . build ( ) ;
6198
+
6199
+ p. cargo ( "package -Zpackage-workspace" )
6200
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6201
+ . with_status ( 101 )
6202
+ . with_stderr_data ( str![ [ r#"
6203
+ [ERROR] `dep` cannot be packaged.
6204
+ The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml.
6205
+
6206
+ "# ] ] )
6207
+ . run ( ) ;
6208
+
6209
+ p. cargo ( "package -Zpackage-workspace --registry=alternative" )
6210
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6211
+ . with_stderr_data ( str![ [ r#"
6212
+ [PACKAGING] dep v0.1.0 ([ROOT]/foo/dep)
6213
+ [PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6214
+ [PACKAGING] main v0.0.1 ([ROOT]/foo/main)
6215
+ [UPDATING] `alternative` index
6216
+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6217
+ [PACKAGING] other v0.1.0 ([ROOT]/foo/other)
6218
+ [PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
6219
+ [VERIFYING] dep v0.1.0 ([ROOT]/foo/dep)
6220
+ [COMPILING] dep v0.1.0 ([ROOT]/foo/target/package/dep-0.1.0)
6221
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
6222
+ [VERIFYING] main v0.0.1 ([ROOT]/foo/main)
6223
+ [UPDATING] `alternative` index
6224
+ [UNPACKING] dep v0.1.0 (registry `[ROOT]/foo/target/package/tmp-registry`)
6225
+ [COMPILING] dep v0.1.0 (registry `alternative`)
6226
+ [COMPILING] main v0.0.1 ([ROOT]/foo/target/package/main-0.0.1)
6227
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
6228
+ [VERIFYING] other v0.1.0 ([ROOT]/foo/other)
6229
+ [COMPILING] other v0.1.0 ([ROOT]/foo/target/package/other-0.1.0)
6230
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
6231
+
6232
+ "# ] ] )
6233
+ . run ( ) ;
6234
+ }
6235
+
6236
+ #[ cargo_test]
6237
+ fn registry_not_inferred_because_of_conflict ( ) {
6238
+ let _alt_reg = registry:: RegistryBuilder :: new ( )
6239
+ . http_api ( )
6240
+ . http_index ( )
6241
+ . alternative ( )
6242
+ . build ( ) ;
6243
+
6244
+ let p = project ( )
6245
+ . file (
6246
+ "Cargo.toml" ,
6247
+ r#"
6248
+ [workspace]
6249
+ members = ["dep", "main"]
6250
+ "# ,
6251
+ )
6252
+ . file (
6253
+ "main/Cargo.toml" ,
6254
+ r#"
6255
+ [package]
6256
+ name = "main"
6257
+ version = "0.0.1"
6258
+ edition = "2015"
6259
+ authors = []
6260
+ license = "MIT"
6261
+ description = "main"
6262
+ repository = "bar"
6263
+ publish = ["alternative"]
6264
+
6265
+ [dependencies]
6266
+ dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
6267
+ "# ,
6268
+ )
6269
+ . file ( "main/src/main.rs" , "fn main() {}" )
6270
+ . file (
6271
+ "dep/Cargo.toml" ,
6272
+ r#"
6273
+ [package]
6274
+ name = "dep"
6275
+ version = "0.1.0"
6276
+ edition = "2015"
6277
+ authors = []
6278
+ license = "MIT"
6279
+ description = "dep"
6280
+ repository = "bar"
6281
+ publish = ["alternative2"]
6282
+ "# ,
6283
+ )
6284
+ . file ( "dep/src/lib.rs" , "" )
6285
+ . build ( ) ;
6286
+
6287
+ p. cargo ( "package -Zpackage-workspace" )
6288
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6289
+ . with_status ( 101 )
6290
+ . with_stderr_data ( str![ [ r#"
6291
+ [ERROR] `dep` cannot be packaged.
6292
+ The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml.
6293
+
6294
+ "# ] ] )
6295
+ . run ( ) ;
6296
+
6297
+ p. cargo ( "package -Zpackage-workspace --registry=alternative" )
6298
+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
6299
+ . with_status ( 101 )
6300
+ . with_stderr_data ( str![ [ r#"
6301
+ [ERROR] `dep` cannot be packaged.
6302
+ The registry `alternative` is not listed in the `package.publish` value in Cargo.toml.
6303
+
6304
+ "# ] ] )
6305
+ . run ( ) ;
6306
+ }
0 commit comments