Module assert_cmd::cargo
source · Expand description
Simplify running bin
s in a Cargo project.
CommandCargoExt
is an extension trait for Command
to easily launch a crate’s
binaries.
Examples
Simple case:
use assert_cmd::prelude::*;
use std::process::Command;
let mut cmd = Command::main_binary()
.unwrap();
let output = cmd.unwrap();
Further customizations
There are times when you might want to drop down to the underlying API, escargot
:
- Specifying feature flags
- Workaround the per-call cargo overhead by caching the binary location with
lazy_static
. - If not using
--target <TRIPLET>
, bypass the first call overhead by not passingcurrent_target()
toescargot
.
extern crate assert_cmd;
extern crate escargot;
use assert_cmd::prelude::*;
use escargot;
use std::process::Command;
let bin_under_test = escargot::CargoBuild::new()
.bin("bin_fixture")
.current_release()
.current_target()
.run()
.unwrap();
let mut cmd = bin_under_test.command();
let output = cmd.unwrap();
Structs
Error when finding crate binary.
Traits
Create a
Command
for a bin
in the Cargo project.