diff --git a/crates/cargo-test-support/src/registry.rs b/crates/cargo-test-support/src/registry.rs index a9d458c0469..7b1dc541a42 100644 --- a/crates/cargo-test-support/src/registry.rs +++ b/crates/cargo-test-support/src/registry.rs @@ -261,6 +261,7 @@ impl RegistryBuilder { let server = HttpServer::new( registry_path.clone(), dl_path, + api_path.clone(), token.clone(), self.auth_required, self.custom_responders, @@ -585,6 +586,7 @@ pub struct HttpServer { listener: TcpListener, registry_path: PathBuf, dl_path: PathBuf, + api_path: PathBuf, addr: SocketAddr, token: Token, auth_required: bool, @@ -604,6 +606,7 @@ impl HttpServer { pub fn new( registry_path: PathBuf, dl_path: PathBuf, + api_path: PathBuf, token: Token, auth_required: bool, api_responders: HashMap< @@ -617,6 +620,7 @@ impl HttpServer { listener, registry_path, dl_path, + api_path, addr, token, auth_required, @@ -1007,6 +1011,12 @@ impl HttpServer { pub fn check_authorized_publish(&self, req: &Request) -> Response { if let Some(body) = &req.body { + // Mimic the publish behavior for local registries by writing out the request + // so tests can verify publishes made to either registry type. + let path = self.api_path.join("api/v1/crates/new"); + t!(fs::create_dir_all(path.parent().unwrap())); + t!(fs::write(&path, body)); + // Get the metadata of the package let (len, remaining) = body.split_at(4); let json_len = u32::from_le_bytes(len.try_into().unwrap()); diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index 6370f133aff..d9bbf47d29d 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -287,7 +287,12 @@ fn cannot_publish_to_crates_io_with_registry_dependency() { #[cargo_test] fn publish_with_registry_dependency() { - registry::alt_init(); + let _reg = RegistryBuilder::new() + .http_api() + .http_index() + .alternative() + .build(); + let p = project() .file( "Cargo.toml", @@ -307,10 +312,26 @@ fn publish_with_registry_dependency() { Package::new("bar", "0.0.1").alternative(true).publish(); - // Login so that we have the token available - p.cargo("login --registry alternative TOKEN").run(); - - p.cargo("publish --registry alternative").run(); + p.cargo("publish --registry alternative") + .with_stderr( + "\ +[UPDATING] `alternative` index +[WARNING] [..] +[..] +[PACKAGING] foo v0.0.1 [..] +[UPDATING] `alternative` index +[VERIFYING] foo v0.0.1 [..] +[DOWNLOADING] [..] +[DOWNLOADED] bar v0.0.1 (registry `alternative`) +[COMPILING] bar v0.0.1 (registry `alternative`) +[COMPILING] foo v0.0.1 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] foo v0.0.1 [..] +[UPDATING] `alternative` index +", + ) + .run(); validate_alt_upload( r#"{ @@ -415,48 +436,43 @@ or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", #[cargo_test] fn publish_to_alt_registry() { - registry::alt_init(); - let p = project().file("src/main.rs", "fn main() {}").build(); - - // Setup the registry by publishing a package - Package::new("bar", "0.0.1").alternative(true).publish(); + let _reg = RegistryBuilder::new() + .http_api() + .http_index() + .alternative() + .build(); - // Login so that we have the token available - p.cargo("login --registry alternative TOKEN").run(); + let p = project().file("src/main.rs", "fn main() {}").build(); // Now perform the actual publish - p.cargo("publish --registry alternative").run(); - - validate_alt_upload( - r#"{ - "authors": [], - "badges": {}, - "categories": [], - "deps": [], - "description": null, - "documentation": null, - "features": {}, - "homepage": null, - "keywords": [], - "license": null, - "license_file": null, - "links": null, - "name": "foo", - "readme": null, - "readme_file": null, - "repository": null, - "homepage": null, - "documentation": null, - "vers": "0.0.1" - }"#, - "foo-0.0.1.crate", - &["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"], - ); + p.cargo("publish --registry alternative") + .with_stderr( + "\ +[UPDATING] `alternative` index +[WARNING] [..] +[..] +[PACKAGING] foo v0.0.1 [..] +[VERIFYING] foo v0.0.1 [..] +[COMPILING] foo v0.0.1 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] foo v0.0.1 [..] +[UPDATING] `alternative` index +", + ) + .run(); } #[cargo_test] fn publish_with_crates_io_dep() { - registry::alt_init(); + // crates.io registry. + let _dummy_reg = registry::init(); + // Alternative registry. + let _alt_reg = RegistryBuilder::new() + .http_api() + .http_index() + .alternative() + .build(); let p = project() .file( "Cargo.toml", @@ -477,10 +493,26 @@ fn publish_with_crates_io_dep() { Package::new("bar", "0.0.1").publish(); - // Login so that we have the token available - p.cargo("login --registry alternative TOKEN").run(); - - p.cargo("publish --registry alternative").run(); + p.cargo("publish --registry alternative") + .with_stderr( + "\ +[UPDATING] `alternative` index +[WARNING] [..] +[..] +[PACKAGING] foo v0.0.1 [..] +[UPDATING] `dummy-registry` index +[VERIFYING] foo v0.0.1 [..] +[DOWNLOADING] [..] +[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`) +[COMPILING] bar v0.0.1 +[COMPILING] foo v0.0.1 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] foo v0.0.1 [..] +[UPDATING] `alternative` index +", + ) + .run(); validate_alt_upload( r#"{ diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 01f5a7c56ed..3e60b51c570 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -2,7 +2,7 @@ //! the new `dep = { artifact = "bin", … }` syntax in manifests. use cargo_test_support::compare::match_exact; -use cargo_test_support::registry::Package; +use cargo_test_support::registry::{Package, RegistryBuilder}; use cargo_test_support::{ basic_bin_manifest, basic_manifest, cross_compile, project, publish, registry, rustc_host, Project, @@ -1872,8 +1872,7 @@ fn env_vars_and_build_products_for_various_build_targets() { #[cargo_test] fn publish_artifact_dep() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); Package::new("bar", "1.0.0").publish(); Package::new("baz", "1.0.0").publish(); @@ -1903,15 +1902,6 @@ fn publish_artifact_dep() { .file("src/lib.rs", "") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish -Z bindeps --no-verify") .replace_crates_io(registry.index_url()) .masquerade_as_nightly_cargo(&["bindeps"]) diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index 88817b736a8..720d221fe1f 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -610,7 +610,10 @@ fn z_flags_rejected() { #[cargo_test] fn publish_allowed() { - let registry = registry::init(); + let registry = registry::RegistryBuilder::new() + .http_api() + .http_index() + .build(); let p = project() .file( @@ -627,16 +630,23 @@ fn publish_allowed() { .file("src/lib.rs", "") .build(); - // HACK: Inject `a` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("a", "0.0.1").file("src/lib.rs", "").publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) .masquerade_as_nightly_cargo(&["test-dummy-unstable"]) + .with_stderr( + "\ +[UPDATING] [..] +[WARNING] [..] +[..] +[PACKAGING] a v0.0.1 [..] +[VERIFYING] a v0.0.1 [..] +[COMPILING] a v0.0.1 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] a v0.0.1 [..] +[UPDATING] [..] +", + ) .run(); } diff --git a/tests/testsuite/credential_process.rs b/tests/testsuite/credential_process.rs index cd1794bda93..0d174b6e379 100644 --- a/tests/testsuite/credential_process.rs +++ b/tests/testsuite/credential_process.rs @@ -1,6 +1,6 @@ //! Tests for credential-process. -use cargo_test_support::registry::{Package, TestRegistry}; +use cargo_test_support::registry::TestRegistry; use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, Project}; use std::fs::{self, read_to_string}; @@ -69,6 +69,8 @@ or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN fn warn_both_token_and_process() { // Specifying both credential-process and a token in config should issue a warning. let _server = registry::RegistryBuilder::new() + .http_api() + .http_index() .alternative() .no_configure_token() .build(); @@ -77,7 +79,7 @@ fn warn_both_token_and_process() { ".cargo/config", r#" [registries.alternative] - token = "sekrit" + token = "alternative-sekrit" credential-process = "false" "#, ) @@ -96,16 +98,6 @@ fn warn_both_token_and_process() { .file("src/lib.rs", "") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .alternative(true) - .publish(); - p.cargo("publish --no-verify --registry alternative -Z credential-process") .masquerade_as_nightly_cargo(&["credential-process"]) .with_status(101) @@ -127,7 +119,7 @@ Only one of these values may be set, remove one or the other to proceed. credential-process = "false" [registries.alternative] - token = "sekrit" + token = "alternative-sekrit" "#, ); p.cargo("publish --no-verify --registry alternative -Z credential-process") diff --git a/tests/testsuite/features_namespaced.rs b/tests/testsuite/features_namespaced.rs index f7c29feef9b..26c4d0ac53e 100644 --- a/tests/testsuite/features_namespaced.rs +++ b/tests/testsuite/features_namespaced.rs @@ -1,7 +1,7 @@ //! Tests for namespaced features. use super::features2::switch_to_resolver_2; -use cargo_test_support::registry::{self, Dependency, Package}; +use cargo_test_support::registry::{Dependency, Package, RegistryBuilder}; use cargo_test_support::{project, publish}; #[cargo_test] @@ -858,8 +858,7 @@ bar v1.0.0 #[cargo_test] fn publish_no_implicit() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); // Does not include implicit features or dep: syntax on publish. Package::new("opt-dep1", "1.0.0").publish(); @@ -887,15 +886,6 @@ fn publish_no_implicit() { .file("src/lib.rs", "") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_stderr( @@ -984,8 +974,7 @@ feat = ["opt-dep1"] #[cargo_test] fn publish() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); // Publish behavior with explicit dep: syntax. Package::new("bar", "1.0.0").publish(); @@ -1012,15 +1001,6 @@ fn publish() { .file("src/lib.rs", "") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) .with_stderr( @@ -1028,6 +1008,7 @@ fn publish() { [UPDATING] [..] [PACKAGING] foo v0.1.0 [..] [VERIFYING] foo v0.1.0 [..] +[UPDATING] [..] [COMPILING] foo v0.1.0 [..] [FINISHED] [..] [PACKAGED] [..] diff --git a/tests/testsuite/inheritable_workspace_fields.rs b/tests/testsuite/inheritable_workspace_fields.rs index 72de2e4ad21..261808940fb 100644 --- a/tests/testsuite/inheritable_workspace_fields.rs +++ b/tests/testsuite/inheritable_workspace_fields.rs @@ -1,5 +1,5 @@ //! Tests for inheriting Cargo.toml fields with field.workspace = true -use cargo_test_support::registry::{Dependency, Package}; +use cargo_test_support::registry::{Dependency, Package, RegistryBuilder}; use cargo_test_support::{ basic_lib_manifest, basic_manifest, git, path2url, paths, project, publish, registry, }; @@ -107,7 +107,7 @@ Caused by: #[cargo_test] fn inherit_own_workspace_fields() { - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project().build(); @@ -160,18 +160,23 @@ fn inherit_own_workspace_fields() { .file("bar.txt", "") // should be included when packaging .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "1.2.3") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) + .with_stderr( + "\ +[UPDATING] [..] +[WARNING] [..] +[..] +[VERIFYING] foo v1.2.3 [..] +[COMPILING] foo v1.2.3 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] foo v1.2.3 [..] +[UPDATING] [..] +", + ) .run(); + publish::validate_upload_with_contents( r#" { @@ -242,7 +247,7 @@ repository = "https://gitlab.com/rust-lang/rust" #[cargo_test] fn inherit_own_dependencies() { - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( "Cargo.toml", @@ -282,8 +287,8 @@ fn inherit_own_dependencies() { "\ [UPDATING] `[..]` index [DOWNLOADING] crates ... -[DOWNLOADED] dep-build v0.8.2 ([..]) [DOWNLOADED] dep v0.1.2 ([..]) +[DOWNLOADED] dep-build v0.8.2 ([..]) [CHECKING] dep v0.1.2 [CHECKING] bar v0.2.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -297,18 +302,26 @@ fn inherit_own_dependencies() { assert!(lockfile.contains("dep-dev")); assert!(lockfile.contains("dep-build")); - // HACK: Inject `bar` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("bar", "0.2.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) + .with_stderr( + "\ +[UPDATING] [..] +[WARNING] [..] +[..] +[PACKAGING] bar v0.2.0 [..] +[UPDATING] [..] +[VERIFYING] bar v0.2.0 [..] +[COMPILING] dep v0.1.2 +[COMPILING] bar v0.2.0 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] bar v0.2.0 [..] +[UPDATING] [..] +", + ) .run(); + publish::validate_upload_with_contents( r#" { @@ -387,7 +400,7 @@ version = "0.8" #[cargo_test] fn inherit_own_detailed_dependencies() { - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( "Cargo.toml", @@ -431,18 +444,26 @@ fn inherit_own_detailed_dependencies() { let lockfile = p.read_lockfile(); assert!(lockfile.contains("dep")); - // HACK: Inject `bar` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("bar", "0.2.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) + .with_stderr( + "\ +[UPDATING] [..] +[WARNING] [..] +[..] +[PACKAGING] bar v0.2.0 [..] +[UPDATING] [..] +[VERIFYING] bar v0.2.0 [..] +[COMPILING] dep v0.1.2 +[COMPILING] bar v0.2.0 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] bar v0.2.0 [..] +[UPDATING] [..] +", + ) .run(); + publish::validate_upload_with_contents( r#" { @@ -593,7 +614,7 @@ fn inherited_dependencies_union_features() { #[cargo_test] fn inherit_workspace_fields() { - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project().build(); @@ -657,19 +678,28 @@ fn inherit_workspace_fields() { .file("bar/bar.txt", "") // should be included when packaging .build(); - // HACK: Inject `bar` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("bar", "1.2.3") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) .cwd("bar") + .with_stderr( + "\ +[UPDATING] [..] +[WARNING] [..] +[..] +[VERIFYING] bar v1.2.3 [..] +[WARNING] [..] +[..] +[..] +[..] +[COMPILING] bar v1.2.3 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] bar v1.2.3 [..] +[UPDATING] [..] +", + ) .run(); + publish::validate_upload_with_contents( r#" { @@ -746,7 +776,7 @@ repository = "https://gitlab.com/rust-lang/rust" #[cargo_test] fn inherit_dependencies() { - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( "Cargo.toml", @@ -787,8 +817,8 @@ fn inherit_dependencies() { "\ [UPDATING] `[..]` index [DOWNLOADING] crates ... -[DOWNLOADED] dep-build v0.8.2 ([..]) [DOWNLOADED] dep v0.1.2 ([..]) +[DOWNLOADED] dep-build v0.8.2 ([..]) [CHECKING] dep v0.1.2 [CHECKING] bar v0.2.0 ([CWD]/bar) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -802,19 +832,27 @@ fn inherit_dependencies() { assert!(lockfile.contains("dep-dev")); assert!(lockfile.contains("dep-build")); - // HACK: Inject `bar` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("bar", "0.2.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) .cwd("bar") + .with_stderr( + "\ +[UPDATING] [..] +[WARNING] [..] +[..] +[PACKAGING] bar v0.2.0 [..] +[UPDATING] [..] +[VERIFYING] bar v0.2.0 [..] +[COMPILING] dep v0.1.2 +[COMPILING] bar v0.2.0 [..] +[FINISHED] [..] +[PACKAGED] [..] +[UPLOADING] bar v0.2.0 [..] +[UPDATING] [..] +", + ) .run(); + publish::validate_upload_with_contents( r#" { diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index 5d868127acc..e3f86905d4c 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -2,7 +2,7 @@ use cargo_test_support::git::{self, repo}; use cargo_test_support::paths; -use cargo_test_support::registry::{self, Package, Response}; +use cargo_test_support::registry::{self, Package, RegistryBuilder, Response}; use cargo_test_support::{basic_manifest, no_such_file_err_msg, project, publish}; use std::fs; use std::sync::{Arc, Mutex}; @@ -87,8 +87,7 @@ fn validate_upload_li() { #[cargo_test] fn simple() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( @@ -105,15 +104,6 @@ fn simple() { .file("src/main.rs", "fn main() {}") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.0.1") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_stderr( @@ -782,8 +772,11 @@ fn publish_empty_list() { #[cargo_test] fn publish_allowed_registry() { - // HACK below allows us to use a local registry - registry::alt_init(); + let _registry = RegistryBuilder::new() + .http_api() + .http_index() + .alternative() + .build(); let p = project().build(); @@ -806,16 +799,6 @@ fn publish_allowed_registry() { .file("src/main.rs", "fn main() {}") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.0.1") - .file("src/lib.rs", "") - .alternative(true) - .publish(); - p.cargo("publish --registry alternative") .with_stderr( "\ @@ -846,8 +829,11 @@ fn publish_allowed_registry() { #[cargo_test] fn publish_implicitly_to_only_allowed_registry() { - // HACK below allows us to use a local registry - registry::alt_init(); + let _registry = RegistryBuilder::new() + .http_api() + .http_index() + .alternative() + .build(); let p = project().build(); @@ -870,16 +856,6 @@ fn publish_implicitly_to_only_allowed_registry() { .file("src/main.rs", "fn main() {}") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.0.1") - .file("src/lib.rs", "") - .alternative(true) - .publish(); - p.cargo("publish") .with_stderr( "\ @@ -1157,8 +1133,7 @@ fn publish_with_no_default_features() { #[cargo_test] fn publish_with_patch() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); Package::new("bar", "1.0.0").publish(); let p = project() @@ -1201,15 +1176,6 @@ fn publish_with_patch() { // Remove the usage of new functionality and try again. p.change_file("src/main.rs", "extern crate bar; pub fn main() {}"); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.0.1") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) .with_stderr( @@ -1218,6 +1184,7 @@ fn publish_with_patch() { [..] [..] [..] +[UPDATING] crates.io index [VERIFYING] foo v0.0.1 ([CWD]) [..] [..] @@ -1366,8 +1333,7 @@ include `--registry crates-io` to use crates.io // A dependency with both `git` and `version`. #[cargo_test] fn publish_git_with_version() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); Package::new("dep1", "1.0.1") .file("src/lib.rs", "pub fn f() -> i32 {1}") @@ -1410,15 +1376,6 @@ fn publish_git_with_version() { p.cargo("run").with_stdout("2").run(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_stderr( @@ -1428,6 +1385,7 @@ fn publish_git_with_version() { [..] [..] [..] +[..] [UPLOADING] foo v0.1.0 ([CWD]) [UPDATING] crates.io index ", @@ -1515,8 +1473,7 @@ fn publish_git_with_version() { #[cargo_test] fn publish_dev_dep_no_version() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( @@ -1541,15 +1498,6 @@ fn publish_dev_dep_no_version() { .file("bar/src/lib.rs", "") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish --no-verify") .replace_crates_io(registry.index_url()) .with_stderr( @@ -2023,8 +1971,7 @@ Caused by: #[cargo_test] fn in_package_workspace() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( @@ -2052,13 +1999,6 @@ fn in_package_workspace() { .file("li/src/main.rs", "fn main() {}") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("li", "0.0.1").file("src/lib.rs", "").publish(); - p.cargo("publish -p li --no-verify") .replace_crates_io(registry.index_url()) .with_stderr( @@ -2131,8 +2071,7 @@ fn with_duplicate_spec_in_members() { #[cargo_test] fn in_package_workspace_with_members_with_features_old() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); let p = project() .file( @@ -2159,13 +2098,6 @@ fn in_package_workspace_with_members_with_features_old() { .file("li/src/main.rs", "fn main() {}") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("li", "0.0.1").file("src/lib.rs", "").publish(); - p.cargo("publish -p li --no-verify") .replace_crates_io(registry.index_url()) .with_stderr( diff --git a/tests/testsuite/weak_dep_features.rs b/tests/testsuite/weak_dep_features.rs index 4e3cd8dcb63..dfc1e6b794e 100644 --- a/tests/testsuite/weak_dep_features.rs +++ b/tests/testsuite/weak_dep_features.rs @@ -2,7 +2,7 @@ use super::features2::switch_to_resolver_2; use cargo_test_support::paths::CargoPathExt; -use cargo_test_support::registry::{self, Dependency, Package}; +use cargo_test_support::registry::{Dependency, Package, RegistryBuilder}; use cargo_test_support::{project, publish}; use std::fmt::Write; @@ -523,8 +523,7 @@ bar v1.0.0 #[cargo_test] fn publish() { - // HACK below allows us to use a local registry - let registry = registry::init(); + let registry = RegistryBuilder::new().http_api().http_index().build(); // Publish behavior with /? syntax. Package::new("bar", "1.0.0").feature("feat", &[]).publish(); @@ -550,15 +549,6 @@ fn publish() { .file("src/lib.rs", "") .build(); - // HACK: Inject `foo` directly into the index so `publish` won't block for it to be in - // the index. - // - // This is to ensure we can verify the Summary we post to the registry as doing so precludes - // the registry from processing the publish. - Package::new("foo", "0.1.0") - .file("src/lib.rs", "") - .publish(); - p.cargo("publish") .replace_crates_io(registry.index_url()) .with_stderr( @@ -566,6 +556,7 @@ fn publish() { [UPDATING] [..] [PACKAGING] foo v0.1.0 [..] [VERIFYING] foo v0.1.0 [..] +[UPDATING] [..] [COMPILING] foo v0.1.0 [..] [FINISHED] [..] [PACKAGED] [..]