lightweight_command_runner/
lib.rs

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