Skip to content

Commit 64f5d10

Browse files
committed
test(carog-tree): new --prune option
1 parent b5998ae commit 64f5d10

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

tests/testsuite/tree.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,3 +1720,81 @@ c v1.0.0
17201720
)
17211721
.run();
17221722
}
1723+
1724+
#[cargo_test]
1725+
fn prune() {
1726+
let p = make_simple_proj();
1727+
1728+
p.cargo("tree --prune c")
1729+
.with_stdout(
1730+
"\
1731+
foo v0.1.0 ([..]/foo)
1732+
└── a v1.0.0
1733+
└── b v1.0.0
1734+
[build-dependencies]
1735+
└── bdep v1.0.0
1736+
└── b v1.0.0 (*)
1737+
[dev-dependencies]
1738+
└── devdep v1.0.0
1739+
└── b v1.0.0 (*)
1740+
",
1741+
)
1742+
.run();
1743+
1744+
// multiple prune
1745+
p.cargo("tree --prune c --prune bdep")
1746+
.with_stdout(
1747+
"\
1748+
foo v0.1.0 ([..]/foo)
1749+
└── a v1.0.0
1750+
└── b v1.0.0
1751+
[build-dependencies]
1752+
[dev-dependencies]
1753+
└── devdep v1.0.0
1754+
└── b v1.0.0 (*)
1755+
",
1756+
)
1757+
.run();
1758+
1759+
// with edge-kinds
1760+
p.cargo("tree --prune c -e normal")
1761+
.with_stdout(
1762+
"\
1763+
foo v0.1.0 ([..]/foo)
1764+
└── a v1.0.0
1765+
└── b v1.0.0
1766+
",
1767+
)
1768+
.run();
1769+
1770+
// pruning self does not works
1771+
p.cargo("tree --prune foo")
1772+
.with_stdout(
1773+
"\
1774+
foo v0.1.0 ([..]/foo)
1775+
├── a v1.0.0
1776+
│ └── b v1.0.0
1777+
│ └── c v1.0.0
1778+
└── c v1.0.0
1779+
[build-dependencies]
1780+
└── bdep v1.0.0
1781+
└── b v1.0.0 (*)
1782+
[dev-dependencies]
1783+
└── devdep v1.0.0
1784+
└── b v1.0.0 (*)
1785+
",
1786+
)
1787+
.run();
1788+
1789+
// dep not exist
1790+
p.cargo("tree --prune no-dep")
1791+
.with_stderr(
1792+
"\
1793+
[ERROR] package ID specification `no-dep` did not match any packages
1794+
1795+
<tab>Did you mean `bdep`?
1796+
",
1797+
)
1798+
.with_status(101)
1799+
.run();
1800+
}

0 commit comments

Comments
 (0)