add tests for preserve features sorted and usorted

This commit is contained in:
Flowrey 2024-04-01 11:10:00 +02:00
parent a59aba136a
commit 5b90c4bbde
11 changed files with 190 additions and 0 deletions

View File

@ -111,7 +111,9 @@ 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;
mod preserve_features_unsorted;
mod preserve_sorted;
mod preserve_unsorted;
mod public;

View File

@ -0,0 +1,9 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
edition = "2015"
[dependencies]
my-package = { version = "99999.0.0", features = ["a", "b", "c", "e"] }

View File

@ -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]
fn case() {
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("my-package", "99999.0.0+my-package")
.feature("a", &[])
.feature("b", &[])
.feature("c", &[])
.feature("d", &[])
.feature("e", &[])
.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("my-package -F d")
.current_dir(cwd)
.assert()
.success()
.stdout_matches(str![""])
.stderr_matches(file!["stderr.term.svg"]);
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
}

View File

@ -0,0 +1,9 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
edition = "2015"
[dependencies]
my-package = { version = "99999.0.0", features = ["a", "b", "c", "e", "d"] }

View File

@ -0,0 +1,43 @@
<svg width="740px" height="200px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }
.fg-green { fill: #00AA00 }
.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 v99999.0.0 to dependencies</tspan>
</tspan>
<tspan x="10px" y="64px"><tspan> Features:</tspan>
</tspan>
<tspan x="10px" y="82px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> a</tspan>
</tspan>
<tspan x="10px" y="100px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> b</tspan>
</tspan>
<tspan x="10px" y="118px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> c</tspan>
</tspan>
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> d</tspan>
</tspan>
<tspan x="10px" y="154px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> e</tspan>
</tspan>
<tspan x="10px" y="172px"><tspan class="fg-green bold"> Locking</tspan><tspan> 2 packages</tspan>
</tspan>
<tspan x="10px" y="190px">
</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,9 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
edition = "2015"
[dependencies]
my-package = { version = "99999.0.0", features = ["b", "a", "d", "c"] }

View File

@ -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]
fn case() {
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("my-package", "99999.0.0+my-package")
.feature("a", &[])
.feature("b", &[])
.feature("c", &[])
.feature("d", &[])
.feature("e", &[])
.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("my-package -F e")
.current_dir(cwd)
.assert()
.success()
.stdout_matches(str![""])
.stderr_matches(file!["stderr.term.svg"]);
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
}

View File

@ -0,0 +1,9 @@
[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
edition = "2015"
[dependencies]
my-package = { version = "99999.0.0", features = ["b", "a", "d", "c", "e"] }

View File

@ -0,0 +1,43 @@
<svg width="740px" height="200px" xmlns="http://www.w3.org/2000/svg">
<style>
.fg { fill: #AAAAAA }
.bg { background: #000000 }
.fg-green { fill: #00AA00 }
.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 v99999.0.0 to dependencies</tspan>
</tspan>
<tspan x="10px" y="64px"><tspan> Features:</tspan>
</tspan>
<tspan x="10px" y="82px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> a</tspan>
</tspan>
<tspan x="10px" y="100px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> b</tspan>
</tspan>
<tspan x="10px" y="118px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> c</tspan>
</tspan>
<tspan x="10px" y="136px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> d</tspan>
</tspan>
<tspan x="10px" y="154px"><tspan> </tspan><tspan class="fg-green bold">+</tspan><tspan> e</tspan>
</tspan>
<tspan x="10px" y="172px"><tspan class="fg-green bold"> Locking</tspan><tspan> 2 packages</tspan>
</tspan>
<tspan x="10px" y="190px">
</tspan>
</text>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB