mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
feat: add tests for similarly named features
This commit is contained in:
parent
49e2f84edd
commit
e29810c327
@ -0,0 +1,7 @@
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
name = "cargo-list-test-fixture"
|
||||
version = "0.0.0"
|
||||
edition = "2024"
|
||||
|
24
tests/testsuite/cargo_add/feature_suggestion_multiple/mod.rs
Normal file
24
tests/testsuite/cargo_add/feature_suggestion_multiple/mod.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use cargo_test_support::current_dir;
|
||||
use cargo_test_support::file;
|
||||
use cargo_test_support::prelude::*;
|
||||
use cargo_test_support::Project;
|
||||
|
||||
#[cargo_test]
|
||||
fn case() {
|
||||
let project = Project::from_template(current_dir!().join("in"));
|
||||
let project_root = project.root();
|
||||
let cwd = &project_root;
|
||||
|
||||
cargo_test_support::registry::Package::new("my-package", "0.1.0+my-package")
|
||||
.feature("bar", &[])
|
||||
.feature("foo", &[])
|
||||
.publish();
|
||||
|
||||
snapbox::cmd::Command::cargo_ui()
|
||||
.arg("add")
|
||||
.arg_line("my-package --features baz --features feo")
|
||||
.current_dir(cwd)
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr_eq(file!["stderr.term.svg"]);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<svg width="740px" height="146px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-red { fill: #AA0000 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Adding</tspan><tspan> my-package v0.1.0 to dependencies</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-red bold">error</tspan><tspan class="bold">:</tspan><tspan> unrecognized features for crate my-package: baz, feo</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan>disabled features:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan> bar, foo</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,7 @@
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
name = "cargo-list-test-fixture"
|
||||
version = "0.0.0"
|
||||
edition = "2024"
|
||||
|
24
tests/testsuite/cargo_add/feature_suggestion_none/mod.rs
Normal file
24
tests/testsuite/cargo_add/feature_suggestion_none/mod.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use cargo_test_support::current_dir;
|
||||
use cargo_test_support::file;
|
||||
use cargo_test_support::prelude::*;
|
||||
use cargo_test_support::Project;
|
||||
|
||||
#[cargo_test]
|
||||
fn case() {
|
||||
let project = Project::from_template(current_dir!().join("in"));
|
||||
let project_root = project.root();
|
||||
let cwd = &project_root;
|
||||
|
||||
cargo_test_support::registry::Package::new("my-package", "0.1.0+my-package")
|
||||
.feature("bar", &[])
|
||||
.feature("foo", &[])
|
||||
.publish();
|
||||
|
||||
snapbox::cmd::Command::cargo_ui()
|
||||
.arg("add")
|
||||
.arg_line("my-package --features none_existent")
|
||||
.current_dir(cwd)
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr_eq(file!["stderr.term.svg"]);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<svg width="740px" height="146px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-red { fill: #AA0000 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Adding</tspan><tspan> my-package v0.1.0 to dependencies</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-red bold">error</tspan><tspan class="bold">:</tspan><tspan> unrecognized feature for crate my-package: none_existent</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan>disabled features:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan> bar, foo</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,7 @@
|
||||
[workspace]
|
||||
|
||||
[package]
|
||||
name = "cargo-list-test-fixture"
|
||||
version = "0.0.0"
|
||||
edition = "2024"
|
||||
|
23
tests/testsuite/cargo_add/feature_suggestion_single/mod.rs
Normal file
23
tests/testsuite/cargo_add/feature_suggestion_single/mod.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use cargo_test_support::current_dir;
|
||||
use cargo_test_support::file;
|
||||
use cargo_test_support::prelude::*;
|
||||
use cargo_test_support::Project;
|
||||
|
||||
#[cargo_test]
|
||||
fn case() {
|
||||
let project = Project::from_template(current_dir!().join("in"));
|
||||
let project_root = project.root();
|
||||
let cwd = &project_root;
|
||||
|
||||
cargo_test_support::registry::Package::new("my-package", "0.1.0+my-package")
|
||||
.feature("bar", &[])
|
||||
.publish();
|
||||
|
||||
snapbox::cmd::Command::cargo_ui()
|
||||
.arg("add")
|
||||
.arg_line("my-package --features baz")
|
||||
.current_dir(cwd)
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr_eq(file!["stderr.term.svg"]);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<svg width="740px" height="146px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-red { fill: #AA0000 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Adding</tspan><tspan> my-package v0.1.0 to dependencies</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-red bold">error</tspan><tspan class="bold">:</tspan><tspan> unrecognized feature for crate my-package: baz</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan>disabled features:</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan> bar</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
@ -21,6 +21,9 @@ mod dev_existing_path_base;
|
||||
mod dev_prefer_existing_version;
|
||||
mod dry_run;
|
||||
mod empty_dep_name;
|
||||
mod feature_suggestion_multiple;
|
||||
mod feature_suggestion_none;
|
||||
mod feature_suggestion_single;
|
||||
mod features;
|
||||
mod features_activated_over_limit;
|
||||
mod features_deactivated_over_limit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user