From b7b036f3a1598598ce1bf3792eaf9c10faa5c21d Mon Sep 17 00:00:00 2001 From: Lin Yihai Date: Mon, 4 Dec 2023 11:25:38 +0800 Subject: [PATCH] Chore(test): remove unnecesary packages and versions for optionals tests --- tests/testsuite/cargo_add/mod.rs | 1 + tests/testsuite/cargo_add/no_optional/mod.rs | 16 ++-------------- .../cargo_add/no_optional/out/Cargo.toml | 3 +-- tests/testsuite/cargo_add/no_optional/stderr.log | 3 +-- tests/testsuite/cargo_add/optional/mod.rs | 16 ++-------------- .../testsuite/cargo_add/optional/out/Cargo.toml | 6 ++---- tests/testsuite/cargo_add/optional/stderr.log | 3 +-- .../overwrite_no_optional/in/Cargo.toml | 3 +-- .../cargo_add/overwrite_no_optional/mod.rs | 16 ++-------------- .../overwrite_no_optional/out/Cargo.toml | 3 +-- .../cargo_add/overwrite_no_optional/stderr.log | 3 +-- .../in/Cargo.toml | 3 +-- .../overwrite_no_optional_with_optional/mod.rs | 16 ++-------------- .../out/Cargo.toml | 6 ++---- .../stderr.log | 3 +-- .../cargo_add/overwrite_optional/in/Cargo.toml | 3 +-- .../cargo_add/overwrite_optional/mod.rs | 16 ++-------------- .../cargo_add/overwrite_optional/out/Cargo.toml | 6 ++---- .../cargo_add/overwrite_optional/stderr.log | 3 +-- .../in/Cargo.toml | 1 - .../overwrite_optional_with_no_optional/mod.rs | 14 ++------------ .../out/Cargo.toml | 1 - .../stderr.log | 1 - .../overwrite_optional_with_optional/mod.rs | 12 +----------- .../overwrite_optional_with_optional/stderr.log | 1 - 25 files changed, 30 insertions(+), 129 deletions(-) diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index 5a1136d33fa..47f5ba0e574 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -87,6 +87,7 @@ mod overwrite_no_public; mod overwrite_no_public_with_public; mod overwrite_optional; mod overwrite_optional_with_no_optional; +mod overwrite_optional_with_optional; mod overwrite_path_noop; mod overwrite_path_with_version; mod overwrite_preserves_inline_table; diff --git a/tests/testsuite/cargo_add/no_optional/mod.rs b/tests/testsuite/cargo_add/no_optional/mod.rs index 9145528bfa3..cc7e79b9761 100644 --- a/tests/testsuite/cargo_add/no_optional/mod.rs +++ b/tests/testsuite/cargo_add/no_optional/mod.rs @@ -7,19 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for name in ["my-package1", "my-package2"] { - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new(name, ver).publish(); - } - } + cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); let project = Project::from_template(curr_dir!().join("in")); let project_root = project.root(); @@ -27,7 +15,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("my-package1 my-package2@0.4.1 --no-optional") + .arg_line("my-package --no-optional") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/no_optional/out/Cargo.toml b/tests/testsuite/cargo_add/no_optional/out/Cargo.toml index c5e01789281..496ac8a6236 100644 --- a/tests/testsuite/cargo_add/no_optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/no_optional/out/Cargo.toml @@ -5,5 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = "99999.0.0" -my-package2 = "0.4.1" +my-package = "0.1.0" diff --git a/tests/testsuite/cargo_add/no_optional/stderr.log b/tests/testsuite/cargo_add/no_optional/stderr.log index fb8d4903d7b..8e025739f48 100644 --- a/tests/testsuite/cargo_add/no_optional/stderr.log +++ b/tests/testsuite/cargo_add/no_optional/stderr.log @@ -1,3 +1,2 @@ Updating `dummy-registry` index - Adding my-package1 v99999.0.0 to dependencies. - Adding my-package2 v0.4.1 to dependencies. + Adding my-package v0.1.0 to dependencies. diff --git a/tests/testsuite/cargo_add/optional/mod.rs b/tests/testsuite/cargo_add/optional/mod.rs index 408a46ed3b3..8daaa961d79 100644 --- a/tests/testsuite/cargo_add/optional/mod.rs +++ b/tests/testsuite/cargo_add/optional/mod.rs @@ -7,19 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for name in ["my-package1", "my-package2"] { - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new(name, ver).publish(); - } - } + cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); let project = Project::from_template(curr_dir!().join("in")); let project_root = project.root(); @@ -27,7 +15,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("my-package1 my-package2@0.4.1 --optional") + .arg_line("my-package --optional") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/optional/out/Cargo.toml b/tests/testsuite/cargo_add/optional/out/Cargo.toml index 5ed3b820ef4..a8789b033b5 100644 --- a/tests/testsuite/cargo_add/optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/optional/out/Cargo.toml @@ -5,9 +5,7 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = { version = "99999.0.0", optional = true } -my-package2 = { version = "0.4.1", optional = true } +my-package = { version = "0.1.0", optional = true } [features] -my-package1 = ["dep:my-package1"] -my-package2 = ["dep:my-package2"] +my-package = ["dep:my-package"] diff --git a/tests/testsuite/cargo_add/optional/stderr.log b/tests/testsuite/cargo_add/optional/stderr.log index 8cf4812cf17..595ac276b48 100644 --- a/tests/testsuite/cargo_add/optional/stderr.log +++ b/tests/testsuite/cargo_add/optional/stderr.log @@ -1,3 +1,2 @@ Updating `dummy-registry` index - Adding my-package1 v99999.0.0 to optional dependencies. - Adding my-package2 v0.4.1 to optional dependencies. + Adding my-package v0.1.0 to optional dependencies. diff --git a/tests/testsuite/cargo_add/overwrite_no_optional/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_optional/in/Cargo.toml index c5e01789281..496ac8a6236 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_optional/in/Cargo.toml @@ -5,5 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = "99999.0.0" -my-package2 = "0.4.1" +my-package = "0.1.0" diff --git a/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs b/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs index 9145528bfa3..cc7e79b9761 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs +++ b/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs @@ -7,19 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for name in ["my-package1", "my-package2"] { - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new(name, ver).publish(); - } - } + cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); let project = Project::from_template(curr_dir!().join("in")); let project_root = project.root(); @@ -27,7 +15,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("my-package1 my-package2@0.4.1 --no-optional") + .arg_line("my-package --no-optional") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/overwrite_no_optional/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_optional/out/Cargo.toml index c5e01789281..496ac8a6236 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_optional/out/Cargo.toml @@ -5,5 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = "99999.0.0" -my-package2 = "0.4.1" +my-package = "0.1.0" diff --git a/tests/testsuite/cargo_add/overwrite_no_optional/stderr.log b/tests/testsuite/cargo_add/overwrite_no_optional/stderr.log index fb8d4903d7b..8e025739f48 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional/stderr.log +++ b/tests/testsuite/cargo_add/overwrite_no_optional/stderr.log @@ -1,3 +1,2 @@ Updating `dummy-registry` index - Adding my-package1 v99999.0.0 to dependencies. - Adding my-package2 v0.4.1 to dependencies. + Adding my-package v0.1.0 to dependencies. diff --git a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/in/Cargo.toml index 8cd2616d4ef..98e2f7da162 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/in/Cargo.toml @@ -5,5 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = { version = "99999.0.0", optional = false } -my-package2 = { version = "0.4.1", optional = false } +my-package = { version = "0.1.0", optional = false } diff --git a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs index 408a46ed3b3..8daaa961d79 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs +++ b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs @@ -7,19 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for name in ["my-package1", "my-package2"] { - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new(name, ver).publish(); - } - } + cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); let project = Project::from_template(curr_dir!().join("in")); let project_root = project.root(); @@ -27,7 +15,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("my-package1 my-package2@0.4.1 --optional") + .arg_line("my-package --optional") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/out/Cargo.toml index 5ed3b820ef4..a8789b033b5 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/out/Cargo.toml @@ -5,9 +5,7 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = { version = "99999.0.0", optional = true } -my-package2 = { version = "0.4.1", optional = true } +my-package = { version = "0.1.0", optional = true } [features] -my-package1 = ["dep:my-package1"] -my-package2 = ["dep:my-package2"] +my-package = ["dep:my-package"] diff --git a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/stderr.log b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/stderr.log index 8cf4812cf17..595ac276b48 100644 --- a/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/stderr.log +++ b/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/stderr.log @@ -1,3 +1,2 @@ Updating `dummy-registry` index - Adding my-package1 v99999.0.0 to optional dependencies. - Adding my-package2 v0.4.1 to optional dependencies. + Adding my-package v0.1.0 to optional dependencies. diff --git a/tests/testsuite/cargo_add/overwrite_optional/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_optional/in/Cargo.toml index c5e01789281..496ac8a6236 100644 --- a/tests/testsuite/cargo_add/overwrite_optional/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_optional/in/Cargo.toml @@ -5,5 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = "99999.0.0" -my-package2 = "0.4.1" +my-package = "0.1.0" diff --git a/tests/testsuite/cargo_add/overwrite_optional/mod.rs b/tests/testsuite/cargo_add/overwrite_optional/mod.rs index 408a46ed3b3..8daaa961d79 100644 --- a/tests/testsuite/cargo_add/overwrite_optional/mod.rs +++ b/tests/testsuite/cargo_add/overwrite_optional/mod.rs @@ -7,19 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for name in ["my-package1", "my-package2"] { - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new(name, ver).publish(); - } - } + cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); let project = Project::from_template(curr_dir!().join("in")); let project_root = project.root(); @@ -27,7 +15,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("my-package1 my-package2@0.4.1 --optional") + .arg_line("my-package --optional") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/overwrite_optional/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_optional/out/Cargo.toml index 5ed3b820ef4..a8789b033b5 100644 --- a/tests/testsuite/cargo_add/overwrite_optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_optional/out/Cargo.toml @@ -5,9 +5,7 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = { version = "99999.0.0", optional = true } -my-package2 = { version = "0.4.1", optional = true } +my-package = { version = "0.1.0", optional = true } [features] -my-package1 = ["dep:my-package1"] -my-package2 = ["dep:my-package2"] +my-package = ["dep:my-package"] diff --git a/tests/testsuite/cargo_add/overwrite_optional/stderr.log b/tests/testsuite/cargo_add/overwrite_optional/stderr.log index 8cf4812cf17..595ac276b48 100644 --- a/tests/testsuite/cargo_add/overwrite_optional/stderr.log +++ b/tests/testsuite/cargo_add/overwrite_optional/stderr.log @@ -1,3 +1,2 @@ Updating `dummy-registry` index - Adding my-package1 v99999.0.0 to optional dependencies. - Adding my-package2 v0.4.1 to optional dependencies. + Adding my-package v0.1.0 to optional dependencies. diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/in/Cargo.toml index 5ef95320946..a7722da07c7 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/in/Cargo.toml @@ -10,4 +10,3 @@ other = ["your-face/nose"] [dependencies] your-face = { version = "99999.0.0", optional = true } -my-package2 = { version = "0.4.1", optional = true } diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs index 3090a752787..511b31e29a0 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs +++ b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs @@ -7,17 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new("my-package2", ver).publish(); - } + cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package") .feature("nose", &[]) .feature("mouth", &[]) @@ -31,7 +21,7 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("add") - .arg_line("your-face my-package2@0.4.1 --no-optional") + .arg_line("your-face --no-optional") .current_dir(cwd) .assert() .success() diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml index bf6c52963b8..b57286ed575 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml @@ -10,4 +10,3 @@ other = ["your-face/nose"] [dependencies] your-face = { version = "99999.0.0" } -my-package2 = { version = "0.4.1" } diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/stderr.log b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/stderr.log index 5fe113e86c7..796b9601b4d 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/stderr.log +++ b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/stderr.log @@ -5,4 +5,3 @@ - eyes - mouth - nose - Adding my-package2 v0.4.1 to dependencies. diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_optional/mod.rs b/tests/testsuite/cargo_add/overwrite_optional_with_optional/mod.rs index 3b498c326de..434124e938a 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_optional/mod.rs +++ b/tests/testsuite/cargo_add/overwrite_optional_with_optional/mod.rs @@ -7,17 +7,7 @@ use cargo_test_support::curr_dir; #[cargo_test] fn case() { cargo_test_support::registry::init(); - for ver in [ - "0.1.1+my-package", - "0.2.0+my-package", - "0.2.3+my-package", - "0.4.1+my-package", - "20.0.0+my-package", - "99999.0.0+my-package", - "99999.0.0-alpha.1+my-package", - ] { - cargo_test_support::registry::Package::new("my-package1", ver).publish(); - } + cargo_test_support::registry::Package::new("my-package1", "99999.0.0").publish(); let project = Project::from_template(curr_dir!().join("in")); let project_root = project.root(); diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_optional/stderr.log b/tests/testsuite/cargo_add/overwrite_optional_with_optional/stderr.log index 8cf4812cf17..ba9cb313d14 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_optional/stderr.log +++ b/tests/testsuite/cargo_add/overwrite_optional_with_optional/stderr.log @@ -1,3 +1,2 @@ Updating `dummy-registry` index Adding my-package1 v99999.0.0 to optional dependencies. - Adding my-package2 v0.4.1 to optional dependencies.