diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 4a4c22b468e..ed36c31f331 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -856,7 +856,13 @@ impl<'gctx> Source for RegistrySource<'gctx> { } any_pending |= self .index - .query_inner(name_permutation, &req, &mut *self.ops, f)? + .query_inner(name_permutation, &req, &mut *self.ops, &mut |s| { + if !s.is_yanked() { + f(s); + } else if kind == QueryKind::Alternatives { + f(s); + } + })? .is_pending(); } } diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index ec00ba48c8a..35ab71346c6 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -2,9 +2,7 @@ mod add_basic; mod add_multiple; mod add_no_vendored_package_with_alter_registry; mod add_no_vendored_package_with_vendor; -mod add_normalized_name_external; mod add_toolchain; -mod add_workspace_non_fuzzy; mod build; mod build_prefer_existing_version; mod change_rename_target; @@ -14,7 +12,6 @@ mod deprecated_default_features; mod deprecated_section; mod detect_workspace_inherit; mod detect_workspace_inherit_features; -mod detect_workspace_inherit_fuzzy; mod detect_workspace_inherit_optional; mod detect_workspace_inherit_path_base; mod detect_workspace_inherit_public; @@ -28,7 +25,6 @@ mod features; mod features_activated_over_limit; mod features_deactivated_over_limit; mod features_empty; -mod features_fuzzy; mod features_multiple_occurrences; mod features_preserve; mod features_spaced_values; @@ -42,7 +38,6 @@ mod git_inferred_name; mod git_inferred_name_multiple; mod git_multiple_names; mod git_multiple_packages_features; -mod git_normalized_name; mod git_registry; mod git_rev; mod git_tag; @@ -75,6 +70,13 @@ mod no_args; mod no_default_features; mod no_optional; mod no_public; +mod normalize_name_git; +mod normalize_name_path; +mod normalize_name_path_existing; +mod normalize_name_registry; +mod normalize_name_registry_existing; +mod normalize_name_registry_yanked; +mod normalize_name_workspace_dep; mod offline_empty_cache; mod optional; mod overwrite_default_features; @@ -118,7 +120,6 @@ mod path_base_unstable; mod path_dev; mod path_inferred_name; mod path_inferred_name_conflicts_full_feature; -mod path_normalized_name; mod preserve_dep_std_table; mod preserve_features_sorted; mod preserve_features_table; @@ -149,3 +150,4 @@ mod vers; mod workspace_name; mod workspace_path; mod workspace_path_dev; +mod yanked; diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/in b/tests/testsuite/cargo_add/normalize_name_git/in similarity index 100% rename from tests/testsuite/cargo_add/add_normalized_name_external/in rename to tests/testsuite/cargo_add/normalize_name_git/in diff --git a/tests/testsuite/cargo_add/git_normalized_name/mod.rs b/tests/testsuite/cargo_add/normalize_name_git/mod.rs similarity index 100% rename from tests/testsuite/cargo_add/git_normalized_name/mod.rs rename to tests/testsuite/cargo_add/normalize_name_git/mod.rs diff --git a/tests/testsuite/cargo_add/git_normalized_name/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_git/out/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/git_normalized_name/out/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_git/out/Cargo.toml diff --git a/tests/testsuite/cargo_add/git_normalized_name/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_git/stderr.term.svg similarity index 100% rename from tests/testsuite/cargo_add/git_normalized_name/stderr.term.svg rename to tests/testsuite/cargo_add/normalize_name_git/stderr.term.svg diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/dependency/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/in/dependency/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/in/dependency/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path/in/dependency/Cargo.toml diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path/in/dependency/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_path/in/dependency/src/lib.rs diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/in/primary/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/in/primary/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path/in/primary/Cargo.toml diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path/in/primary/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_path/in/primary/src/lib.rs diff --git a/tests/testsuite/cargo_add/path_normalized_name/mod.rs b/tests/testsuite/cargo_add/normalize_name_path/mod.rs similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/mod.rs rename to tests/testsuite/cargo_add/normalize_name_path/mod.rs diff --git a/tests/testsuite/cargo_add/path_normalized_name/out/dependency/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/out/dependency/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/out/dependency/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path/out/dependency/Cargo.toml diff --git a/tests/testsuite/cargo_add/path_normalized_name/out/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path/out/primary/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/out/primary/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path/out/primary/Cargo.toml diff --git a/tests/testsuite/cargo_add/path_normalized_name/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_path/stderr.term.svg similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/stderr.term.svg rename to tests/testsuite/cargo_add/normalize_name_path/stderr.term.svg diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock b/tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.lock similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.lock rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.lock diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/Cargo.toml diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/fuzzy_name/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/Cargo.toml diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/fuzzy_name/src/lib.rs diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/in/primary/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/Cargo.toml diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_path_existing/in/primary/src/lib.rs diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/mod.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/mod.rs similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/mod.rs rename to tests/testsuite/cargo_add/normalize_name_path_existing/mod.rs diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/out/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path_existing/out/Cargo.toml diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/out/primary/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/Cargo.toml diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_path_existing/out/primary/src/lib.rs diff --git a/tests/testsuite/cargo_add/add_workspace_non_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_path_existing/stderr.term.svg similarity index 100% rename from tests/testsuite/cargo_add/add_workspace_non_fuzzy/stderr.term.svg rename to tests/testsuite/cargo_add/normalize_name_path_existing/stderr.term.svg diff --git a/tests/testsuite/cargo_add/git_normalized_name/in b/tests/testsuite/cargo_add/normalize_name_registry/in similarity index 100% rename from tests/testsuite/cargo_add/git_normalized_name/in rename to tests/testsuite/cargo_add/normalize_name_registry/in diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs b/tests/testsuite/cargo_add/normalize_name_registry/mod.rs similarity index 100% rename from tests/testsuite/cargo_add/add_normalized_name_external/mod.rs rename to tests/testsuite/cargo_add/normalize_name_registry/mod.rs diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry/out/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/add_normalized_name_external/out/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_registry/out/Cargo.toml diff --git a/tests/testsuite/cargo_add/add_normalized_name_external/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_registry/stderr.term.svg similarity index 100% rename from tests/testsuite/cargo_add/add_normalized_name_external/stderr.term.svg rename to tests/testsuite/cargo_add/normalize_name_registry/stderr.term.svg diff --git a/tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry_existing/in/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_registry_existing/in/Cargo.toml diff --git a/tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_registry_existing/in/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_registry_existing/in/src/lib.rs diff --git a/tests/testsuite/cargo_add/features_fuzzy/mod.rs b/tests/testsuite/cargo_add/normalize_name_registry_existing/mod.rs similarity index 100% rename from tests/testsuite/cargo_add/features_fuzzy/mod.rs rename to tests/testsuite/cargo_add/normalize_name_registry_existing/mod.rs diff --git a/tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry_existing/out/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_registry_existing/out/Cargo.toml diff --git a/tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_registry_existing/stderr.term.svg similarity index 100% rename from tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg rename to tests/testsuite/cargo_add/normalize_name_registry_existing/stderr.term.svg diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/in b/tests/testsuite/cargo_add/normalize_name_registry_yanked/in new file mode 120000 index 00000000000..6c6a27fcfb5 --- /dev/null +++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/in @@ -0,0 +1 @@ +../add-basic.in \ No newline at end of file diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs b/tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs new file mode 100644 index 00000000000..4b3bedb34ea --- /dev/null +++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/mod.rs @@ -0,0 +1,31 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::current_dir; +use cargo_test_support::file; +use cargo_test_support::prelude::*; +use cargo_test_support::str; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + cargo_test_support::registry::init(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.5.0").publish(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4").publish(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.6.0") + .yanked(true) + .publish(); + + let project = Project::from_template(current_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("linked_hash_map") + .current_dir(cwd) + .assert() + .success() + .stdout_eq(str![""]) + .stderr_eq(file!["stderr.term.svg"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml new file mode 100644 index 00000000000..89e018f0e01 --- /dev/null +++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/out/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" +edition = "2015" + +[dependencies] +linked-hash-map = "0.5.4" diff --git a/tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg new file mode 100644 index 00000000000..4766fc1a798 --- /dev/null +++ b/tests/testsuite/cargo_add/normalize_name_registry_yanked/stderr.term.svg @@ -0,0 +1,34 @@ + + + + + + + Updating `dummy-registry` index + + warning: translating `linked_hash_map` to `linked-hash-map` + + Adding linked-hash-map v0.5.4 to dependencies + + Locking 1 package to latest compatible version + + + + + + diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/in/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/in/Cargo.toml diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/in/primary/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/Cargo.toml diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/dependency/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/in/dependency/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/in/primary/src/lib.rs diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/mod.rs b/tests/testsuite/cargo_add/normalize_name_workspace_dep/mod.rs similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/mod.rs rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/mod.rs diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/out/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/out/Cargo.toml diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/Cargo.toml b/tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/Cargo.toml similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/out/primary/Cargo.toml rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/Cargo.toml diff --git a/tests/testsuite/cargo_add/path_normalized_name/in/primary/src/lib.rs b/tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/src/lib.rs similarity index 100% rename from tests/testsuite/cargo_add/path_normalized_name/in/primary/src/lib.rs rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/out/primary/src/lib.rs diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/normalize_name_workspace_dep/stderr.term.svg similarity index 100% rename from tests/testsuite/cargo_add/detect_workspace_inherit_fuzzy/stderr.term.svg rename to tests/testsuite/cargo_add/normalize_name_workspace_dep/stderr.term.svg diff --git a/tests/testsuite/cargo_add/yanked/in b/tests/testsuite/cargo_add/yanked/in new file mode 120000 index 00000000000..6c6a27fcfb5 --- /dev/null +++ b/tests/testsuite/cargo_add/yanked/in @@ -0,0 +1 @@ +../add-basic.in \ No newline at end of file diff --git a/tests/testsuite/cargo_add/yanked/mod.rs b/tests/testsuite/cargo_add/yanked/mod.rs new file mode 100644 index 00000000000..050943fe897 --- /dev/null +++ b/tests/testsuite/cargo_add/yanked/mod.rs @@ -0,0 +1,31 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::current_dir; +use cargo_test_support::file; +use cargo_test_support::prelude::*; +use cargo_test_support::str; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + cargo_test_support::registry::init(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.5.0").publish(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4").publish(); + cargo_test_support::registry::Package::new("linked-hash-map", "0.6.0") + .yanked(true) + .publish(); + + let project = Project::from_template(current_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("linked-hash-map") + .current_dir(cwd) + .assert() + .success() + .stdout_eq(str![""]) + .stderr_eq(file!["stderr.term.svg"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/yanked/out/Cargo.toml b/tests/testsuite/cargo_add/yanked/out/Cargo.toml new file mode 100644 index 00000000000..89e018f0e01 --- /dev/null +++ b/tests/testsuite/cargo_add/yanked/out/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" +edition = "2015" + +[dependencies] +linked-hash-map = "0.5.4" diff --git a/tests/testsuite/cargo_add/yanked/stderr.term.svg b/tests/testsuite/cargo_add/yanked/stderr.term.svg new file mode 100644 index 00000000000..cf47fc90e6d --- /dev/null +++ b/tests/testsuite/cargo_add/yanked/stderr.term.svg @@ -0,0 +1,31 @@ + + + + + + + Updating `dummy-registry` index + + Adding linked-hash-map v0.5.4 to dependencies + + Locking 1 package to latest compatible version + + + + + +