Macro cradle::run_output [−][src]
macro_rules! run_output {
($($args : tt) *) => { ... };
}
Expand description
Execute child processes, and capture some output. For example you can capture what the child process writes to stdout:
use cradle::prelude::*;
let StdoutUntrimmed(output) = run_output!(%"echo foo");
assert_eq!(output, "foo\n");
run_output!
uses return-type polymorphism.
So by using a different return type,
you can control what outputs of child processes you want to capture.
Here’s an example to capture an exit code:
use cradle::prelude::*;
let Status(status) = run_output!("false");
assert_eq!(status.code(), Some(1));
You can use any type that implements crate::output::Output
as the return type.
See the module documentation for more comprehensive documentation.