@@ -4370,6 +4370,101 @@ fn all_unpublishable_packages() {
43704370 . run ( ) ;
43714371}
43724372
4373+ #[ cargo_test]
4374+ fn all_published_packages ( ) {
4375+ let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
4376+
4377+ let p = project ( )
4378+ . file (
4379+ "Cargo.toml" ,
4380+ r#"
4381+ [workspace]
4382+ members = ["foo", "bar"]
4383+ "# ,
4384+ )
4385+ . file (
4386+ "foo/Cargo.toml" ,
4387+ r#"
4388+ [package]
4389+ name = "foo"
4390+ version = "0.0.0"
4391+ edition = "2015"
4392+ license = "MIT"
4393+ description = "foo"
4394+ repository = "foo"
4395+ "# ,
4396+ )
4397+ . file ( "foo/src/lib.rs" , "" )
4398+ . file (
4399+ "bar/Cargo.toml" ,
4400+ r#"
4401+ [package]
4402+ name = "bar"
4403+ version = "0.0.0"
4404+ edition = "2015"
4405+ license = "MIT"
4406+ description = "foo"
4407+ repository = "foo"
4408+ "# ,
4409+ )
4410+ . file ( "bar/src/lib.rs" , "" )
4411+ . build ( ) ;
4412+
4413+ // First, publish all members
4414+ p. cargo ( "publish --workspace --no-verify" )
4415+ . replace_crates_io ( registry. index_url ( ) )
4416+ . with_stderr_data ( str![ [ r#"
4417+ [UPDATING] crates.io index
4418+ [PACKAGING] bar v0.0.0 ([ROOT]/foo/bar)
4419+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4420+ [PACKAGING] foo v0.0.0 ([ROOT]/foo/foo)
4421+ [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
4422+ [UPLOADING] bar v0.0.0 ([ROOT]/foo/bar)
4423+ [UPLOADED] bar v0.0.0 to registry `crates-io`
4424+ [UPLOADING] foo v0.0.0 ([ROOT]/foo/foo)
4425+ [UPLOADED] foo v0.0.0 to registry `crates-io`
4426+ [NOTE] waiting for bar v0.0.0 or foo v0.0.0 to be available at registry `crates-io`
4427+ [HELP] you may press ctrl-c to skip waiting; the crates should be available shortly
4428+ [PUBLISHED] bar v0.0.0 and foo v0.0.0 at registry `crates-io`
4429+
4430+ "# ] ] )
4431+ . run ( ) ;
4432+
4433+ // Publishing all members again works
4434+ p. cargo ( "publish --workspace --no-verify" )
4435+ . replace_crates_io ( registry. index_url ( ) )
4436+ . with_status ( 101 )
4437+ . with_stderr_data ( str![ [ r#"
4438+ [UPDATING] crates.io index
4439+ [ERROR] crate [email protected] already exists on crates.io index 4440+
4441+ "# ] ] )
4442+ . run ( ) ;
4443+
4444+ // Without `--workspace` works as it is a virtual workspace
4445+ p. cargo ( "publish --no-verify" )
4446+ . replace_crates_io ( registry. index_url ( ) )
4447+ . with_status ( 101 )
4448+ . with_stderr_data ( str![ [ r#"
4449+ [UPDATING] crates.io index
4450+ [ERROR] crate [email protected] already exists on crates.io index 4451+
4452+ "# ] ] )
4453+ . run ( ) ;
4454+
4455+ // Change a file. It should fail due to checksum verification failure.
4456+ p. change_file ( "bar/src/lib.rs" , "//! foo" ) ;
4457+ p. cargo ( "publish --no-verify" )
4458+ . replace_crates_io ( registry. index_url ( ) )
4459+ . with_status ( 101 )
4460+ . with_stderr_data ( str![ [ r#"
4461+ [UPDATING] crates.io index
4462+ [ERROR] crate [email protected] already exists on crates.io index 4463+
4464+ "# ] ] )
4465+ . run ( ) ;
4466+ }
4467+
43734468#[ cargo_test]
43744469fn checksum_changed ( ) {
43754470 let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
0 commit comments