Skip to content

Commit 83d4440

Browse files
committed
feat(test-support): Make it easy to launch cargo
1 parent 9a3d99b commit 83d4440

File tree

2 files changed

+117
-110
lines changed

2 files changed

+117
-110
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub mod registry;
6060
pub mod tools;
6161

6262
pub mod prelude {
63+
pub use crate::CargoCommand;
6364
pub use crate::ChannelChanger;
6465
pub use crate::TestEnv;
6566
}
@@ -1229,6 +1230,19 @@ impl TestEnv for snapbox::cmd::Command {
12291230
}
12301231
}
12311232

1233+
/// Test the cargo command
1234+
pub trait CargoCommand {
1235+
fn cargo() -> Self;
1236+
}
1237+
1238+
impl CargoCommand for snapbox::cmd::Command {
1239+
fn cargo() -> Self {
1240+
Self::new(cargo_exe())
1241+
.with_assert(compare::assert())
1242+
.test_env()
1243+
}
1244+
}
1245+
12321246
fn split_and_add_args(p: &mut ProcessBuilder, s: &str) {
12331247
for mut arg in s.split_whitespace() {
12341248
if (arg.starts_with('"') && arg.ends_with('"'))

0 commit comments

Comments
 (0)