Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions tests/testsuite/cargo_tree/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,10 @@ foo v0.1.0 ([ROOT]/foo)
#[cargo_test]
fn format() {
Package::new("dep", "1.0.0").publish();
Package::new("other-dep", "1.0.0").publish();
Package::new("dep", "2.0.0").publish();
Package::new("other-dep", "1.0.0")
.dep("dep", "^1.0")
.publish();

Package::new("dep_that_is_awesome", "1.0.0")
.file(
Expand All @@ -1140,6 +1143,10 @@ fn format() {

[lib]
name = "awesome_dep"

[dependencies]
dep1 = {package="dep", version="<2.0"}
dep2 = {package="dep", version="2.0"}
"#,
)
.file("src/lib.rs", "pub struct Straw;")
Expand All @@ -1156,9 +1163,9 @@ fn format() {
repository = "https://github.com/rust-lang/cargo"

[dependencies]
dep = {version="1.0", optional=true}
dep = {version="=1.0"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removing coverage.

I suspect the test changes here should be purely additive rather than mutating existing stuff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also question our having a single format test and wonder if we should break out your new cases into a separate test or even multiple tests

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a good callout, I can work on splitting this out.

other-dep = {version="1.0", optional=true}
dep_that_is_awesome = {version="1.0", optional=true}
dep_that_is_awesome = {version=">=1.0, <2", optional=true}


[features]
Expand All @@ -1173,6 +1180,7 @@ fn format() {
p.cargo("tree --format <<<{p}>>>")
.with_stdout_data(str![[r#"
<<<foo v0.1.0 ([ROOT]/foo)>>>
└── <<<dep v1.0.0>>>

"#]])
.run();
Expand All @@ -1191,6 +1199,7 @@ Caused by:
p.cargo("tree --format {p}-{{hello}}")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo)-{hello}
└── dep v1.0.0-{hello}

"#]])
.run();
Expand All @@ -1199,6 +1208,7 @@ foo v0.1.0 ([ROOT]/foo)-{hello}
.arg("{p} {l} {r}")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo) MIT https://github.com/rust-lang/cargo
└── dep v1.0.0

"#]])
.run();
Expand All @@ -1207,17 +1217,19 @@ foo v0.1.0 ([ROOT]/foo) MIT https://github.com/rust-lang/cargo
.arg("{p} {f}")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo) bar,default,foo
└── dep v1.0.0

"#]])
.run();

p.cargo("tree --all-features --format")
.arg("{p} [{f}]")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo) [bar,default,dep,dep_that_is_awesome,foo,other-dep]
foo v0.1.0 ([ROOT]/foo) [bar,default,dep_that_is_awesome,foo,other-dep]
├── dep v1.0.0 []
├── dep_that_is_awesome v1.0.0 []
└── other-dep v1.0.0 []
└── dep v1.0.0 []

"#]])
.run();
Expand All @@ -1227,8 +1239,34 @@ foo v0.1.0 ([ROOT]/foo) [bar,default,dep,dep_that_is_awesome,foo,other-dep]
.arg("--format={lib}")
.with_stdout_data(str![[r#"

├── dep
├── awesome_dep
└── other_dep
└── dep

"#]])
.run();

p.cargo("tree --all-features")
.arg("--format={p}")
.with_stdout_data(str![[r#"
foo v0.1.0 ([ROOT]/foo)
├── dep v1.0.0
├── dep_that_is_awesome v1.0.0
└── other-dep v1.0.0
└── dep v1.0.0

"#]])
.run();

p.cargo("tree --all-features")
.arg("--format={p}")
.arg("--invert=dep")
.with_stdout_data(str![[r#"
dep v1.0.0
├── foo v0.1.0 ([ROOT]/foo)
└── other-dep v1.0.0
└── foo v0.1.0 ([ROOT]/foo)

"#]])
.run();
Expand Down