@@ -3990,11 +3990,7 @@ You may press ctrl-c to skip waiting; the crate should be available shortly.
39903990
39913991#[ cargo_test]
39923992fn one_unpublishable_package ( ) {
3993- let _alt_reg = registry:: RegistryBuilder :: new ( )
3994- . http_api ( )
3995- . http_index ( )
3996- . alternative ( )
3997- . build ( ) ;
3993+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
39983994
39993995 let p = project ( )
40003996 . file (
@@ -4018,7 +4014,7 @@ fn one_unpublishable_package() {
40184014 publish = false
40194015
40204016 [dependencies]
4021- dep = { path = "../dep", version = "0.1.0", registry = "alternative" }
4017+ dep = { path = "../dep", version = "0.1.0" }
40224018 "# ,
40234019 )
40244020 . file ( "main/src/main.rs" , "fn main() {}" )
@@ -4033,14 +4029,14 @@ fn one_unpublishable_package() {
40334029 license = "MIT"
40344030 description = "dep"
40354031 repository = "bar"
4036- publish = ["alternative"]
40374032 "# ,
40384033 )
40394034 . file ( "dep/src/lib.rs" , "" )
40404035 . build ( ) ;
40414036
40424037 p. cargo ( "publish -Zpackage-workspace" )
40434038 . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4039+ . replace_crates_io ( registry. index_url ( ) )
40444040 . with_status ( 101 )
40454041 . with_stderr_data ( str![ [ r#"
40464042[ERROR] `main` cannot be published.
@@ -4051,19 +4047,15 @@ fn one_unpublishable_package() {
40514047}
40524048
40534049#[ cargo_test]
4054- fn multiple_unpublishable_package ( ) {
4055- let _alt_reg = registry:: RegistryBuilder :: new ( )
4056- . http_api ( )
4057- . http_index ( )
4058- . alternative ( )
4059- . build ( ) ;
4050+ fn virtual_ws_with_multiple_unpublishable_package ( ) {
4051+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
40604052
40614053 let p = project ( )
40624054 . file (
40634055 "Cargo.toml" ,
40644056 r#"
40654057 [workspace]
4066- members = ["dep", "main"]
4058+ members = ["dep", "main", "publishable" ]
40674059 "# ,
40684060 )
40694061 . file (
@@ -4099,10 +4091,24 @@ fn multiple_unpublishable_package() {
40994091 "# ,
41004092 )
41014093 . file ( "dep/src/lib.rs" , "" )
4094+ . file (
4095+ "publishable/Cargo.toml" ,
4096+ r#"
4097+ [package]
4098+ name = "publishable"
4099+ version = "0.1.0"
4100+ edition = "2015"
4101+ license = "MIT"
4102+ description = "foo"
4103+ repository = "foo"
4104+ "# ,
4105+ )
4106+ . file ( "publishable/src/lib.rs" , "" )
41024107 . build ( ) ;
41034108
41044109 p. cargo ( "publish -Zpackage-workspace" )
41054110 . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4111+ . replace_crates_io ( registry. index_url ( ) )
41064112 . with_status ( 101 )
41074113 . with_stderr_data ( str![ [ r#"
41084114[ERROR] `dep`, `main` cannot be published.
@@ -4111,3 +4117,201 @@ fn multiple_unpublishable_package() {
41114117"# ] ] )
41124118 . run ( ) ;
41134119}
4120+
4121+ #[ cargo_test]
4122+ fn workspace_flag_with_unpublishable_packages ( ) {
4123+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
4124+
4125+ let p = project ( )
4126+ . file (
4127+ "Cargo.toml" ,
4128+ r#"
4129+ [workspace]
4130+ members = ["publishable", "non-publishable"]
4131+
4132+ [package]
4133+ name = "cwd"
4134+ version = "0.0.0"
4135+ edition = "2015"
4136+ license = "MIT"
4137+ description = "foo"
4138+ repository = "foo"
4139+ publish = false
4140+ "# ,
4141+ )
4142+ . file ( "src/lib.rs" , "" )
4143+ . file (
4144+ "publishable/Cargo.toml" ,
4145+ r#"
4146+ [package]
4147+ name = "publishable"
4148+ version = "0.0.0"
4149+ edition = "2015"
4150+ license = "MIT"
4151+ description = "foo"
4152+ repository = "foo"
4153+ publish = true
4154+ "# ,
4155+ )
4156+ . file ( "publishable/src/lib.rs" , "" )
4157+ . file (
4158+ "non-publishable/Cargo.toml" ,
4159+ r#"
4160+ [package]
4161+ name = "non-publishable"
4162+ version = "0.0.0"
4163+ edition = "2015"
4164+ license = "MIT"
4165+ description = "foo"
4166+ repository = "foo"
4167+ publish = false
4168+ "# ,
4169+ )
4170+ . file ( "non-publishable/src/lib.rs" , "" )
4171+ . build ( ) ;
4172+
4173+ p. cargo ( "publish --workspace -Zpackage-workspace" )
4174+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4175+ . replace_crates_io ( registry. index_url ( ) )
4176+ . with_status ( 101 )
4177+ . with_stderr_data ( str![ [ r#"
4178+ [ERROR] `non-publishable`, `cwd` cannot be published.
4179+ `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
4180+
4181+ "# ] ] )
4182+ . run ( ) ;
4183+ }
4184+
4185+ #[ cargo_test]
4186+ fn unpublishable_package_as_versioned_dev_dep ( ) {
4187+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
4188+
4189+ let p = project ( )
4190+ . file (
4191+ "Cargo.toml" ,
4192+ r#"
4193+ [workspace]
4194+ members = ["dep", "main"]
4195+ "# ,
4196+ )
4197+ . file (
4198+ "main/Cargo.toml" ,
4199+ r#"
4200+ [package]
4201+ name = "main"
4202+ version = "0.0.1"
4203+ edition = "2015"
4204+ license = "MIT"
4205+ description = "main"
4206+ repository = "bar"
4207+
4208+ [dev-dependencies]
4209+ dep = { path = "../dep", version = "0.1.0" }
4210+ "# ,
4211+ )
4212+ . file ( "main/src/main.rs" , "fn main() {}" )
4213+ . file (
4214+ "dep/Cargo.toml" ,
4215+ r#"
4216+ [package]
4217+ name = "dep"
4218+ version = "0.1.0"
4219+ edition = "2015"
4220+ license = "MIT"
4221+ description = "dep"
4222+ repository = "bar"
4223+ publish = false
4224+ "# ,
4225+ )
4226+ . file ( "dep/src/lib.rs" , "" )
4227+ . build ( ) ;
4228+
4229+ // It is expected to find the versioned dev dep not being published,
4230+ // regardless with `--dry-run` or `--no-verify`.
4231+ p. cargo ( "publish -Zpackage-workspace" )
4232+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4233+ . replace_crates_io ( registry. index_url ( ) )
4234+ . with_status ( 101 )
4235+ . with_stderr_data ( str![ [ r#"
4236+ [ERROR] `dep` cannot be published.
4237+ `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
4238+
4239+ "# ] ] )
4240+ . run ( ) ;
4241+
4242+ p. cargo ( "publish -Zpackage-workspace --dry-run" )
4243+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4244+ . replace_crates_io ( registry. index_url ( ) )
4245+ . with_status ( 101 )
4246+ . with_stderr_data ( str![ [ r#"
4247+ [ERROR] `dep` cannot be published.
4248+ `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
4249+
4250+ "# ] ] )
4251+ . run ( ) ;
4252+
4253+ p. cargo ( "publish -Zpackage-workspace --no-verify" )
4254+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4255+ . replace_crates_io ( registry. index_url ( ) )
4256+ . with_status ( 101 )
4257+ . with_stderr_data ( str![ [ r#"
4258+ [ERROR] `dep` cannot be published.
4259+ `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
4260+
4261+ "# ] ] )
4262+ . run ( ) ;
4263+ }
4264+
4265+ #[ cargo_test]
4266+ fn all_unpublishable_packages ( ) {
4267+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
4268+
4269+ let p = project ( )
4270+ . file (
4271+ "Cargo.toml" ,
4272+ r#"
4273+ [workspace]
4274+ members = ["non-publishable1", "non-publishable2"]
4275+ "# ,
4276+ )
4277+ . file (
4278+ "non-publishable1/Cargo.toml" ,
4279+ r#"
4280+ [package]
4281+ name = "non-publishable1"
4282+ version = "0.0.0"
4283+ edition = "2015"
4284+ license = "MIT"
4285+ description = "foo"
4286+ repository = "foo"
4287+ publish = false
4288+ "# ,
4289+ )
4290+ . file ( "non-publishable1/src/lib.rs" , "" )
4291+ . file (
4292+ "non-publishable2/Cargo.toml" ,
4293+ r#"
4294+ [package]
4295+ name = "non-publishable2"
4296+ version = "0.0.0"
4297+ edition = "2015"
4298+ license = "MIT"
4299+ description = "foo"
4300+ repository = "foo"
4301+ publish = false
4302+ "# ,
4303+ )
4304+ . file ( "non-publishable2/src/lib.rs" , "" )
4305+ . build ( ) ;
4306+
4307+ p. cargo ( "publish --workspace -Zpackage-workspace" )
4308+ . masquerade_as_nightly_cargo ( & [ "package-workspace" ] )
4309+ . replace_crates_io ( registry. index_url ( ) )
4310+ . with_status ( 101 )
4311+ . with_stderr_data ( str![ [ r#"
4312+ [ERROR] `non-publishable1`, `non-publishable2` cannot be published.
4313+ `package.publish` must be set to `true` or a non-empty list in Cargo.toml to publish.
4314+
4315+ "# ] ] )
4316+ . run ( ) ;
4317+ }
0 commit comments