diff options
Diffstat (limited to 'vendor/escargot/src/bin/bin_fixture.rs')
-rw-r--r-- | vendor/escargot/src/bin/bin_fixture.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/escargot/src/bin/bin_fixture.rs b/vendor/escargot/src/bin/bin_fixture.rs new file mode 100644 index 000000000..f47540f85 --- /dev/null +++ b/vendor/escargot/src/bin/bin_fixture.rs @@ -0,0 +1,33 @@ +use std::env; +use std::error::Error; +use std::io; +use std::io::Write; +use std::process; + +fn run() -> Result<(), Box<dyn Error>> { + if let Ok(text) = env::var("stdout") { + println!("{}", text); + } + if let Ok(text) = env::var("stderr") { + eprintln!("{}", text); + } + + let code = env::var("exit") + .ok() + .map(|v| v.parse::<i32>()) + .map(|r| r.map(Some)) + .unwrap_or(Ok(None))? + .unwrap_or(0); + process::exit(code); +} + +fn main() { + let code = match run() { + Ok(_) => 0, + Err(ref e) => { + write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + 1 + } + }; + process::exit(code); +} |