ralph-coder 0.2.1

An agentic code generation CLI powered by multiple LLM backends
Documentation
/// Shell tool tests — run real commands in a TempDir sandbox.
use ralph::tools::shell_tools;
use tempfile::TempDir;

#[tokio::test]
async fn run_echo_command() {
    let dir = TempDir::new().unwrap();
    let output = shell_tools::run_command("echo hello_ralph", dir.path())
        .await
        .unwrap();
    assert!(output.contains("hello_ralph"));
    assert!(output.contains("[exit: 0]"));
}

#[tokio::test]
async fn failing_command_captures_exit_code() {
    let dir = TempDir::new().unwrap();
    let output = shell_tools::run_command("exit 42", dir.path())
        .await
        .unwrap();
    assert!(output.contains("[exit: 42]"));
}

#[tokio::test]
async fn stderr_captured() {
    let dir = TempDir::new().unwrap();
    let output = shell_tools::run_command("echo error_output >&2", dir.path())
        .await
        .unwrap();
    assert!(output.contains("error_output"));
}

#[tokio::test]
async fn command_runs_in_cwd() {
    let dir = TempDir::new().unwrap();
    // Write a file and verify we can ls it from the cwd
    std::fs::write(dir.path().join("sentinel.txt"), "exists").unwrap();
    let output = shell_tools::run_command("ls sentinel.txt", dir.path())
        .await
        .unwrap();
    assert!(output.contains("sentinel.txt"));
}