diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 2a089395f2c..8935d80ab6f 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -1872,7 +1872,9 @@ 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(); + Package::new("bar", "1.0.0").publish(); Package::new("baz", "1.0.0").publish(); @@ -1901,6 +1903,15 @@ 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/credential_process.rs b/tests/testsuite/credential_process.rs index 38c8ca13e11..0939592458b 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::TestRegistry; +use cargo_test_support::registry::{Package, TestRegistry}; use cargo_test_support::{basic_manifest, cargo_process, paths, project, registry, Project}; use std::fs; @@ -94,6 +94,16 @@ 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) diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index aa02a8389f8..4af11afa658 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -66,7 +66,8 @@ fn publish_with_target() { return; } - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( diff --git a/tests/testsuite/features_namespaced.rs b/tests/testsuite/features_namespaced.rs index 8aefdbdc7b4..7d061da5ba9 100644 --- a/tests/testsuite/features_namespaced.rs +++ b/tests/testsuite/features_namespaced.rs @@ -858,7 +858,9 @@ bar v1.0.0 #[cargo_test] fn publish_no_implicit() { + // HACK below allows us to use a local registry let registry = registry::init(); + // Does not include implicit features or dep: syntax on publish. Package::new("opt-dep1", "1.0.0").publish(); Package::new("opt-dep2", "1.0.0").publish(); @@ -885,6 +887,15 @@ 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( @@ -971,7 +982,9 @@ feat = ["opt-dep1"] #[cargo_test] fn publish() { + // HACK below allows us to use a local registry let registry = registry::init(); + // Publish behavior with explicit dep: syntax. Package::new("bar", "1.0.0").publish(); let p = project() @@ -997,6 +1010,15 @@ 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( diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index d0851f62407..24740ce0df3 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -85,22 +85,9 @@ fn validate_upload_li() { ); } -fn validate_upload_foo_clean() { - publish::validate_upload( - CLEAN_FOO_JSON, - "foo-0.0.1.crate", - &[ - "Cargo.lock", - "Cargo.toml", - "Cargo.toml.orig", - "src/main.rs", - ".cargo_vcs_info.json", - ], - ); -} - #[cargo_test] fn simple() { + // HACK below allows us to use a local registry let registry = registry::init(); let p = project() @@ -118,6 +105,15 @@ 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( @@ -138,7 +134,8 @@ See [..] // `[registry]` table. #[cargo_test] fn old_token_location() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( @@ -183,12 +180,14 @@ See [..] ) .run(); - validate_upload_foo(); + // Skip `validate_upload_foo` as we just cared we got far enough for verify the token behavior. + // Other tests will verify the endpoint gets the right payload. } #[cargo_test] fn simple_with_index() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( @@ -220,11 +219,13 @@ fn simple_with_index() { ) .run(); - validate_upload_foo(); + // Skip `validate_upload_foo` as we just cared we got far enough for verify the VCS behavior. + // Other tests will verify the endpoint gets the right payload. } #[cargo_test] fn git_deps() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -262,6 +263,7 @@ the `git` specification will be removed from the dependency declaration. #[cargo_test] fn path_dependency_no_version() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -301,6 +303,7 @@ the `path` specification will be removed from the dependency declaration. #[cargo_test] fn unpublishable_crate() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -333,6 +336,7 @@ The registry `crates-io` is not listed in the `publish` value in Cargo.toml. #[cargo_test] fn dont_publish_dirty() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project().file("bar", "").build(); @@ -374,7 +378,8 @@ to proceed despite this and include the uncommitted changes, pass the `--allow-d #[cargo_test] fn publish_clean() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project().build(); @@ -409,12 +414,14 @@ fn publish_clean() { ) .run(); - validate_upload_foo_clean(); + // Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior. + // Other tests will verify the endpoint gets the right payload. } #[cargo_test] fn publish_in_sub_repo() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project().no_manifest().file("baz", "").build(); @@ -450,12 +457,14 @@ fn publish_in_sub_repo() { ) .run(); - validate_upload_foo_clean(); + // Skip `validate_upload_foo_clean` as we just cared we got far enough for verify the VCS behavior. + // Other tests will verify the endpoint gets the right payload. } #[cargo_test] fn publish_when_ignored() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project().file("baz", "").build(); @@ -491,23 +500,14 @@ fn publish_when_ignored() { ) .run(); - publish::validate_upload( - CLEAN_FOO_JSON, - "foo-0.0.1.crate", - &[ - "Cargo.lock", - "Cargo.toml", - "Cargo.toml.orig", - "src/main.rs", - ".gitignore", - ".cargo_vcs_info.json", - ], - ); + // Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior. + // Other tests will verify the endpoint gets the right payload. } #[cargo_test] fn ignore_when_crate_ignored() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project().no_manifest().file("bar/baz", "").build(); @@ -542,21 +542,13 @@ fn ignore_when_crate_ignored() { ) .run(); - publish::validate_upload( - CLEAN_FOO_JSON, - "foo-0.0.1.crate", - &[ - "Cargo.lock", - "Cargo.toml", - "Cargo.toml.orig", - "src/main.rs", - "baz", - ], - ); + // Skip `validate_upload` as we just cared we got far enough for verify the VCS behavior. + // Other tests will verify the endpoint gets the right payload. } #[cargo_test] fn new_crate_rejected() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project().file("baz", "").build(); @@ -589,6 +581,7 @@ fn new_crate_rejected() { #[cargo_test] fn dry_run() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -692,6 +685,7 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml. #[cargo_test] fn publish_allowed_registry() { + // HACK below allows us to use a local registry registry::alt_init(); let p = project().build(); @@ -715,6 +709,16 @@ 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( "\ @@ -742,6 +746,7 @@ 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 p = project().build(); @@ -765,6 +770,16 @@ 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( "\ @@ -857,7 +872,8 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml. // Explicitly setting `crates-io` in the publish list. #[cargo_test] fn publish_with_crates_io_explicit() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( @@ -903,7 +919,8 @@ The registry `alternative` is not listed in the `publish` value in Cargo.toml. #[cargo_test] fn publish_with_select_features() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( @@ -948,7 +965,8 @@ fn publish_with_select_features() { #[cargo_test] fn publish_with_all_features() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( @@ -993,6 +1011,7 @@ fn publish_with_all_features() { #[cargo_test] fn publish_with_no_default_features() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -1028,6 +1047,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(); Package::new("bar", "1.0.0").publish(); @@ -1071,6 +1091,15 @@ 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( @@ -1226,7 +1255,9 @@ 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(); + Package::new("dep1", "1.0.1") .file("src/lib.rs", "pub fn f() -> i32 {1}") .publish(); @@ -1267,6 +1298,16 @@ fn publish_git_with_version() { .build(); 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( @@ -1360,6 +1401,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 p = project() @@ -1385,6 +1427,15 @@ 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( @@ -1444,7 +1495,8 @@ repository = "foo" #[cargo_test] fn credentials_ambiguous_filename() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let credentials_toml = paths::home().join(".cargo/credentials.toml"); fs::write(credentials_toml, r#"token = "api-token""#).unwrap(); @@ -1477,15 +1529,15 @@ fn credentials_ambiguous_filename() { ", ) .run(); - - validate_upload_foo(); } // --index will not load registry.token to avoid possibly leaking // crates.io token to another server. #[cargo_test] fn index_requires_token() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); + let credentials = paths::home().join(".cargo/credentials"); fs::remove_file(&credentials).unwrap(); @@ -1548,7 +1600,9 @@ include `--registry dummy-registry` or `--registry crates-io` #[cargo_test] fn publish_with_missing_readme() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); + let p = project() .file( "Cargo.toml", @@ -1835,6 +1889,7 @@ Caused by: #[cargo_test] fn in_package_workspace() { + // HACK below allows us to use a local registry let registry = registry::init(); let p = project() @@ -1863,6 +1918,13 @@ 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( @@ -1881,6 +1943,7 @@ See [..] #[cargo_test] fn with_duplicate_spec_in_members() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -1932,6 +1995,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 p = project() @@ -1959,6 +2023,13 @@ 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( @@ -1977,6 +2048,7 @@ See [..] #[cargo_test] fn in_virtual_workspace() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -2012,7 +2084,8 @@ fn in_virtual_workspace() { #[cargo_test] fn in_virtual_workspace_with_p() { - let registry = registry::init(); + // `publish` generally requires a remote registry + let registry = registry::RegistryBuilder::new().http_api().build(); let p = project() .file( @@ -2063,6 +2136,7 @@ See [..] #[cargo_test] fn in_package_workspace_not_found() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -2107,6 +2181,7 @@ error: package ID specification `li` did not match any packages #[cargo_test] fn in_package_workspace_found_multiple() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() @@ -2164,6 +2239,7 @@ error: the `-p` argument must be specified to select a single package to publish #[cargo_test] // https://github.com/rust-lang/cargo/issues/10536 fn publish_path_dependency_without_workspace() { + // Use local registry for faster test times since no publish will occur let registry = registry::init(); let p = project() diff --git a/tests/testsuite/weak_dep_features.rs b/tests/testsuite/weak_dep_features.rs index 1ef12b371ef..e0c06d729cc 100644 --- a/tests/testsuite/weak_dep_features.rs +++ b/tests/testsuite/weak_dep_features.rs @@ -523,7 +523,9 @@ bar v1.0.0 #[cargo_test] fn publish() { + // HACK below allows us to use a local registry let registry = registry::init(); + // Publish behavior with /? syntax. Package::new("bar", "1.0.0").feature("feat", &[]).publish(); let p = project() @@ -548,6 +550,15 @@ 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(