MCPcopy Create free account
hub / github.com/assert-rs/assert_cmd / run

Function run

src/bin/bin_fixture.rs:9–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7use std::process;
8
9fn run() -> Result<(), Box<dyn Error>> {
10 if let Ok(text) = env::var("stdout") {
11 println!("{text}");
12 }
13 if let Ok(text) = env::var("stderr") {
14 eprintln!("{text}");
15 }
16
17 if let Some(timeout) = env::var("sleep").ok().and_then(|s| s.parse().ok()) {
18 std::thread::sleep(std::time::Duration::from_secs(timeout));
19 }
20
21 let code = env::var("exit")
22 .ok()
23 .map(|v| v.parse::<i32>())
24 .map(|r| r.map(Some))
25 .unwrap_or(Ok(None))?
26 .unwrap_or(0);
27 process::exit(code);
28}
29
30fn main() {
31 let code = match run() {

Callers 1

mainFunction · 0.70

Calls 1

okMethod · 0.45

Tested by

no test coverage detected