Skip to content

Commit

Permalink
test: migrate tree_graph_features to snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
eth3lbert committed Jun 18, 2024
1 parent 0fe23ca commit b8914e3
Showing 1 changed file with 99 additions and 112 deletions.
211 changes: 99 additions & 112 deletions tests/testsuite/tree_graph_features.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Tests for the `cargo tree` command with -e features option.
#![allow(deprecated)]

use cargo_test_support::project;
use cargo_test_support::registry::{Dependency, Package};
use cargo_test_support::str;

#[cargo_test]
fn dep_feature_various() {
Expand Down Expand Up @@ -52,41 +51,40 @@ fn dep_feature_various() {
.build();

p.cargo("tree -e features")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
├── nodefaultdep v1.0.0
├── defaultdep feature \"default\"
├── defaultdep feature "default"
│ ├── defaultdep v1.0.0
│ │ └── optdep feature \"default\"
│ │ └── optdep feature "default"
│ │ ├── optdep v1.0.0
│ │ └── optdep feature \"cat\"
│ │ └── optdep feature "cat"
│ │ └── optdep v1.0.0
│ └── defaultdep feature \"f1\"
│ └── defaultdep feature "f1"
│ ├── defaultdep v1.0.0 (*)
│ └── defaultdep feature \"optdep\"
│ └── defaultdep feature "optdep"
│ └── defaultdep v1.0.0 (*)
├── nameddep feature \"default\"
├── nameddep feature "default"
│ ├── nameddep v1.0.0
│ │ └── serde feature \"default\"
│ │ └── serde feature "default"
│ │ └── serde v1.0.0
│ │ └── serde_derive feature \"default\"
│ │ └── serde_derive feature "default"
│ │ └── serde_derive v1.0.0
│ └── nameddep feature \"serde-stuff\"
│ └── nameddep feature "serde-stuff"
│ ├── nameddep v1.0.0 (*)
│ ├── nameddep feature \"serde\"
│ ├── nameddep feature "serde"
│ │ └── nameddep v1.0.0 (*)
│ └── serde feature \"derive\"
│ └── serde feature "derive"
│ ├── serde v1.0.0 (*)
│ └── serde feature \"serde_derive\"
│ └── serde feature "serde_derive"
│ └── serde v1.0.0 (*)
├── nameddep feature \"serde\" (*)
└── nameddep feature \"vehicle\"
├── nameddep feature "serde" (*)
└── nameddep feature "vehicle"
├── nameddep v1.0.0 (*)
└── nameddep feature \"car\"
└── nameddep feature "car"
└── nameddep v1.0.0 (*)
",
)
"#]])
.run();
}

Expand Down Expand Up @@ -135,38 +133,36 @@ fn graph_features_ws_interdependent() {
.build();

p.cargo("tree -e features")
.with_stdout(
"\
.with_stdout_data(str![[r#"
a v0.1.0 ([..]/foo/a)
├── b feature \"default\" (command-line)
├── b feature "default" (command-line)
│ ├── b v0.1.0 ([..]/foo/b)
│ └── b feature \"feat1\"
│ └── b feature "feat1"
│ └── b v0.1.0 ([..]/foo/b)
└── b feature \"feat2\"
└── b feature "feat2"
└── b v0.1.0 ([..]/foo/b)
b v0.1.0 ([..]/foo/b)
",
)
"#]])
.run();

p.cargo("tree -e features -i a -i b")
.with_stdout(
"\
.with_stdout_data(str![[r#"
a v0.1.0 ([..]/foo/a)
├── a feature \"a1\"
│ └── a feature \"default\" (command-line)
└── a feature \"default\" (command-line)
├── a feature "a1"
│ └── a feature "default" (command-line)
└── a feature "default" (command-line)
b v0.1.0 ([..]/foo/b)
├── b feature \"default\" (command-line)
├── b feature "default" (command-line)
│ └── a v0.1.0 ([..]/foo/a) (*)
├── b feature \"feat1\"
│ └── b feature \"default\" (command-line) (*)
└── b feature \"feat2\"
├── b feature "feat1"
│ └── b feature "default" (command-line) (*)
└── b feature "feat2"
└── a v0.1.0 ([..]/foo/a) (*)
",
)
"#]])
.run();
}

Expand Down Expand Up @@ -202,90 +198,84 @@ fn slash_feature_name() {
.build();

p.cargo("tree -e features --features f1")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
├── notopt feature \"default\"
├── notopt feature "default"
│ └── notopt v1.0.0
└── opt feature \"default\"
└── opt feature "default"
└── opt v1.0.0
",
)
"#]])
.run();

p.cargo("tree -e features --features f1 -i foo")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
├── foo feature \"default\" (command-line)
├── foo feature \"f1\" (command-line)
└── foo feature \"opt\"
└── foo feature \"f1\" (command-line)
",
)
├── foo feature "default" (command-line)
├── foo feature "f1" (command-line)
└── foo feature "opt"
└── foo feature "f1" (command-line)
"#]])
.run();

p.cargo("tree -e features --features f1 -i notopt")
.with_stdout(
"\
.with_stdout_data(str![[r#"
notopt v1.0.0
├── notopt feature \"animal\"
│ └── foo feature \"f1\" (command-line)
├── notopt feature \"cat\"
│ └── notopt feature \"animal\" (*)
└── notopt feature \"default\"
├── notopt feature "animal"
│ └── foo feature "f1" (command-line)
├── notopt feature "cat"
│ └── notopt feature "animal" (*)
└── notopt feature "default"
└── foo v0.1.0 ([..]/foo)
├── foo feature \"default\" (command-line)
├── foo feature \"f1\" (command-line)
└── foo feature \"opt\"
└── foo feature \"f1\" (command-line)
",
)
├── foo feature "default" (command-line)
├── foo feature "f1" (command-line)
└── foo feature "opt"
└── foo feature "f1" (command-line)
"#]])
.run();

p.cargo("tree -e features --features notopt/animal -i notopt")
.with_stdout(
"\
.with_stdout_data(str![[r#"
notopt v1.0.0
├── notopt feature \"animal\" (command-line)
├── notopt feature \"cat\"
│ └── notopt feature \"animal\" (command-line)
└── notopt feature \"default\"
├── notopt feature "animal" (command-line)
├── notopt feature "cat"
│ └── notopt feature "animal" (command-line)
└── notopt feature "default"
└── foo v0.1.0 ([..]/foo)
└── foo feature \"default\" (command-line)
",
)
└── foo feature "default" (command-line)
"#]])
.run();

p.cargo("tree -e features --all-features")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
├── notopt feature \"default\"
├── notopt feature "default"
│ └── notopt v1.0.0
├── opt feature \"default\"
├── opt feature "default"
│ └── opt v1.0.0
└── opt2 feature \"default\"
└── opt2 feature "default"
└── opt2 v1.0.0
",
)
"#]])
.run();

p.cargo("tree -e features --all-features -i opt2")
.with_stdout(
"\
.with_stdout_data(str![[r#"
opt2 v1.0.0
└── opt2 feature \"default\"
└── opt2 feature "default"
└── foo v0.1.0 ([..]/foo)
├── foo feature \"default\" (command-line)
├── foo feature \"f1\" (command-line)
│ └── foo feature \"f2\" (command-line)
├── foo feature \"f2\" (command-line)
├── foo feature \"opt\" (command-line)
│ └── foo feature \"f1\" (command-line) (*)
└── foo feature \"opt2\" (command-line)
",
)
├── foo feature "default" (command-line)
├── foo feature "f1" (command-line)
│ └── foo feature "f2" (command-line)
├── foo feature "f2" (command-line)
├── foo feature "opt" (command-line)
│ └── foo feature "f1" (command-line) (*)
└── foo feature "opt2" (command-line)
"#]])
.run();
}

Expand Down Expand Up @@ -330,35 +320,32 @@ fn features_enables_inactive_target() {
.file("src/lib.rs", "")
.build();
p.cargo("tree -e features")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
└── dep2 feature \"default\"
└── dep2 feature "default"
└── dep2 v1.0.0
",
)
"#]])
.run();
p.cargo("tree -e features --all-features")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
└── dep2 feature \"default\"
└── dep2 feature "default"
└── dep2 v1.0.0
",
)
"#]])
.run();
p.cargo("tree -e features --all-features --target=all")
.with_stdout(
"\
.with_stdout_data(str![[r#"
foo v0.1.0 ([..]/foo)
├── dep1 feature \"default\"
├── dep1 feature "default"
│ └── dep1 v1.0.0
├── dep2 feature \"default\"
├── dep2 feature "default"
│ └── dep2 v1.0.0
│ └── optdep feature \"default\"
│ └── optdep feature "default"
│ └── optdep v1.0.0
└── optdep feature \"default\" (*)
",
)
└── optdep feature "default" (*)
"#]])
.run();
}

0 comments on commit b8914e3

Please sign in to comment.