From 9c4c4d1d5e6e3ca6f7fa4129fe6b8672dc032f21 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 | 32 +++++++++++++ .../cargo_add/features_fuzzy/out/Cargo.toml | 9 ++++ .../cargo_add/features_fuzzy/stderr.term.svg | 45 +++++++++++++++++++ tests/testsuite/cargo_add/mod.rs | 1 + 6 files changed, 96 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..f5d96445b289 --- /dev/null +++ b/tests/testsuite/cargo_add/features_fuzzy/mod.rs @@ -0,0 +1,32 @@ +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("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_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/features_fuzzy/out/Cargo.toml b/tests/testsuite/cargo_add/features_fuzzy/out/Cargo.toml new file mode 100644 index 000000000000..a50d1f6d256d --- /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" } 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..8f5778eb5c3a --- /dev/null +++ b/tests/testsuite/cargo_add/features_fuzzy/stderr.term.svg @@ -0,0 +1,45 @@ + + + + + + + Updating `dummy-registry` index + + warning: translating `your-face` to `your_face` + + Adding your_face v99999.0.0 to dependencies + + Features: + + - ears + + - eyes + + - mouth + + - nose + + Locking 1 package to latest compatible version + + + + + + diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index ff96419281b1..efe5680431ab 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -25,6 +25,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;