Skip to content

Commit 2e3adce

Browse files
committed
Update cargo tree format tests with version requirement scenarios
Update cargo tree format tests and introduce different version requirements and new placeholder tests to prepare for the next commits which will add a new formatting option to display package version requirements. Signed-off-by: Alexandre Barone <[email protected]>
1 parent 2952fba commit 2e3adce

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

tests/testsuite/cargo_tree/deps.rs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,10 @@ foo v0.1.0 ([ROOT]/foo)
11281128
#[cargo_test]
11291129
fn format() {
11301130
Package::new("dep", "1.0.0").publish();
1131-
Package::new("other-dep", "1.0.0").publish();
1131+
Package::new("dep", "2.0.0").publish();
1132+
Package::new("other-dep", "1.0.0")
1133+
.dep("dep", "^1.0")
1134+
.publish();
11321135

11331136
Package::new("dep_that_is_awesome", "1.0.0")
11341137
.file(
@@ -1140,6 +1143,10 @@ fn format() {
11401143
11411144
[lib]
11421145
name = "awesome_dep"
1146+
1147+
[dependencies]
1148+
dep1 = {package="dep", version="<2.0"}
1149+
dep2 = {package="dep", version="2.0"}
11431150
"#,
11441151
)
11451152
.file("src/lib.rs", "pub struct Straw;")
@@ -1156,9 +1163,9 @@ fn format() {
11561163
repository = "https://github.com/rust-lang/cargo"
11571164
11581165
[dependencies]
1159-
dep = {version="1.0", optional=true}
1166+
dep = {version="=1.0"}
11601167
other-dep = {version="1.0", optional=true}
1161-
dep_that_is_awesome = {version="1.0", optional=true}
1168+
dep_that_is_awesome = {version=">=1.0, <2", optional=true}
11621169
11631170
11641171
[features]
@@ -1173,6 +1180,7 @@ fn format() {
11731180
p.cargo("tree --format <<<{p}>>>")
11741181
.with_stdout_data(str![[r#"
11751182
<<<foo v0.1.0 ([ROOT]/foo)>>>
1183+
└── <<<dep v1.0.0>>>
11761184
11771185
"#]])
11781186
.run();
@@ -1191,6 +1199,7 @@ Caused by:
11911199
p.cargo("tree --format {p}-{{hello}}")
11921200
.with_stdout_data(str![[r#"
11931201
foo v0.1.0 ([ROOT]/foo)-{hello}
1202+
└── dep v1.0.0-{hello}
11941203
11951204
"#]])
11961205
.run();
@@ -1199,6 +1208,7 @@ foo v0.1.0 ([ROOT]/foo)-{hello}
11991208
.arg("{p} {l} {r}")
12001209
.with_stdout_data(str![[r#"
12011210
foo v0.1.0 ([ROOT]/foo) MIT https://github.com/rust-lang/cargo
1211+
└── dep v1.0.0
12021212
12031213
"#]])
12041214
.run();
@@ -1207,17 +1217,19 @@ foo v0.1.0 ([ROOT]/foo) MIT https://github.com/rust-lang/cargo
12071217
.arg("{p} {f}")
12081218
.with_stdout_data(str![[r#"
12091219
foo v0.1.0 ([ROOT]/foo) bar,default,foo
1220+
└── dep v1.0.0
12101221
12111222
"#]])
12121223
.run();
12131224

12141225
p.cargo("tree --all-features --format")
12151226
.arg("{p} [{f}]")
12161227
.with_stdout_data(str![[r#"
1217-
foo v0.1.0 ([ROOT]/foo) [bar,default,dep,dep_that_is_awesome,foo,other-dep]
1228+
foo v0.1.0 ([ROOT]/foo) [bar,default,dep_that_is_awesome,foo,other-dep]
12181229
├── dep v1.0.0 []
12191230
├── dep_that_is_awesome v1.0.0 []
12201231
└── other-dep v1.0.0 []
1232+
└── dep v1.0.0 []
12211233
12221234
"#]])
12231235
.run();
@@ -1227,8 +1239,34 @@ foo v0.1.0 ([ROOT]/foo) [bar,default,dep,dep_that_is_awesome,foo,other-dep]
12271239
.arg("--format={lib}")
12281240
.with_stdout_data(str![[r#"
12291241
1242+
├── dep
12301243
├── awesome_dep
12311244
└── other_dep
1245+
└── dep
1246+
1247+
"#]])
1248+
.run();
1249+
1250+
p.cargo("tree --all-features")
1251+
.arg("--format={p}")
1252+
.with_stdout_data(str![[r#"
1253+
foo v0.1.0 ([ROOT]/foo)
1254+
├── dep v1.0.0
1255+
├── dep_that_is_awesome v1.0.0
1256+
└── other-dep v1.0.0
1257+
└── dep v1.0.0
1258+
1259+
"#]])
1260+
.run();
1261+
1262+
p.cargo("tree --all-features")
1263+
.arg("--format={p}")
1264+
.arg("--invert=dep")
1265+
.with_stdout_data(str![[r#"
1266+
dep v1.0.0
1267+
├── foo v0.1.0 ([ROOT]/foo)
1268+
└── other-dep v1.0.0
1269+
└── foo v0.1.0 ([ROOT]/foo)
12321270
12331271
"#]])
12341272
.run();

0 commit comments

Comments
 (0)