Expand description
the simple invoke command for test
This invokes external a command and manipulates standard in out.
You can use std::process::Command more easily.
§Features
- minimum support rustc 1.58.0 (02072b482 2022-01-11)
§Reproducible Tests and Environment
To ensure reproducible test results across different environments, exec-target is opinionated about environment variables.
By default, it clears the environment and only inherits a minimal set of essential variables:
TERMTZPATHLD_LIBRARY_PATH
Additionally, it explicitly sets LANG=C to avoid localized output from commands (e.g., error messages in different languages), which would otherwise make string assertions fragile.
§Example
use exec_target::exec_target_with_env_in;
let command = "target/debug/exe-stab-grep";
let args = &["--color=always", "-e", "c"];
let envs = vec![("GREP_COLORS", "ms=01;32")];
let inp = b"abcdefg\n" as &[u8];
let oup = exec_target_with_env_in(command, args, envs, inp).unwrap();
assert_eq!(oup.stderr, "");
assert_eq!(oup.stdout, "ab\u{1b}[01;32m\u{1b}[Kc\u{1b}[m\u{1b}[Kdefg\n");
assert_eq!(oup.status.success(), true);Structs§
- Output
String - Captured output from an executed command.
Enums§
- Exec
Error - Error type for command execution.
Functions§
- args_
from - parse a command line strings
- exec_
target - exec_
target_ with_ env - exec_
target_ with_ env_ in - This invokes external a command and manipulates standard in out.
You can use
std::process::Commandmore easily. - exec_
target_ with_ in