lightweight_command_runner/
lib.rs1#[macro_use] mod imports; use imports::*;
3
4x!{command_runner}
5x!{exit_status}
6
7#[cfg(test)]
8mod test_default_command_runner {
9 use super::*;
10 use tokio::process::Command;
11
12 #[tokio::test]
14 async fn should_run_echo_command_successfully() {
15 let runner = DefaultCommandRunner;
16 let mut cmd = if cfg!(target_os = "windows") {
18 let mut c = Command::new("cmd");
19 c.args(["/C", "echo hello"]);
20 c
21 } else {
22 let mut c = Command::new("echo");
23 c.arg("hello");
24 c
25 };
26
27 let output = runner.run_command(cmd).await;
28 assert!(output.is_ok(), "Command should run successfully");
29
30 let output = output.unwrap();
31 let stdout = String::from_utf8_lossy(&output.stdout);
32 assert!(stdout.contains("hello"), "Output should contain 'hello'");
33 }
34}