From 39c1d77de4e7542e8a0442eee2303b67c4b7fd7f Mon Sep 17 00:00:00 2001 From: Jonas Dohse Date: Wed, 17 Apr 2024 08:40:39 +0200 Subject: [PATCH] Add test case for feature adding with fuzzy name #10680 --- .../cargo_add/features_fuzzy/in/Cargo.toml | 9 ++++ .../cargo_add/features_fuzzy/in/src/lib.rs | 0 .../testsuite/cargo_add/features_fuzzy/mod.rs | 33 +++++++++++++++ .../cargo_add/features_fuzzy/out/Cargo.toml | 9 ++++ .../cargo_add/features_fuzzy/stderr.term.svg | 42 +++++++++++++++++++ tests/testsuite/cargo_add/mod.rs | 1 + 6 files changed, 94 insertions(+) create mode 100644 tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml create mode 100644 tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs create mode 100644 tests/testsuite/cargo_add/features_fuzzy/mod.rs create mode 100644 tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml create mode 100644 tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg diff --git a/tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml b/tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml new file mode 100644 index 000000000000..62909ec87fde --- /dev/null +++ b/tests/testsuite/cargo_add/features_fuzzy/in/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" +edition = "2015" + +[dependencies] +your_face = { version = "99999.0.0", features = ["eyes"] } \ No newline at end of file diff --git a/tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs b/tests/testsuite/cargo_add/features_fuzzy/in/src/lib.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/features_fuzzy/mod.rs b/tests/testsuite/cargo_add/features_fuzzy/mod.rs new file mode 100644 index 000000000000..e39db7220578 --- /dev/null +++ b/tests/testsuite/cargo_add/features_fuzzy/mod.rs @@ -0,0 +1,33 @@ +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] +#[ignore] +fn case() { + cargo_test_support::registry::init(); + cargo_test_support::registry::Package::new("your_face", "99999.0.0+my-package") + .feature("nose", &[]) + .feature("mouth", &[]) + .feature("eyes", &[]) + .feature("ears", &[]) + .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("your_face") + .current_dir(cwd) + .assert() + .success() + .stdout_matches(str![""]) + .stderr_matches(file!["stderr.term.svg"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml new file mode 100644 index 000000000000..42049792df28 --- /dev/null +++ b/tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" +edition = "2015" + +[dependencies] +your_face = { version = "99999.0.0", features = ["eyes"] } diff --git a/tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg b/tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg new file mode 100644 index 000000000000..9442c2a1f3a4 --- /dev/null +++ b/tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg @@ -0,0 +1,42 @@ + + + + + + + Updating `dummy-registry` index + + Adding your_face v99999.0.0 to dependencies + + Features: + + + eyes + + - ears + + - mouth + + - nose + + Locking 2 packages to latest compatible versions + + + + + + diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index b32f8a6d6080..e373fced7a45 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -26,6 +26,7 @@ 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;