#![allow(clippy::ignore_without_reason)] #![allow(missing_docs)]
use assert_cmd::Command;
#[test]
#[ignore = "RED phase: Will hang indefinitely"]
fn test_runtime_090_01_command_output_simple() {
let ruchy_script = r#"
use std::process::Command
println("Starting...")
let result = Command::new("ls").output()
println("Done!")
"#;
let temp_file = std::env::temp_dir().join("test_command_simple.ruchy");
std::fs::write(&temp_file, ruchy_script).unwrap();
let output = Command::new("timeout")
.arg("5") .arg("ruchy")
.arg("run")
.arg(&temp_file)
.output()
.expect("Failed to run ruchy");
let _ = std::fs::remove_file(&temp_file);
assert!(
!output.status.success(),
"Command should timeout due to hang"
);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("Starting..."), "Should print before hang");
assert!(
!stdout.contains("Done!"),
"Should NOT reach after .output() call"
);
}
#[test]
#[ignore = "RED phase: Will hang indefinitely"]
fn test_runtime_090_02_command_output_with_args() {
let ruchy_script = r#"
use std::process::Command
println("Starting...")
let mut cmd = Command::new("echo")
cmd.arg("hello")
let result = cmd.output()
println("Done!")
"#;
let temp_file = std::env::temp_dir().join("test_command_args.ruchy");
std::fs::write(&temp_file, ruchy_script).unwrap();
let output = Command::new("timeout")
.arg("5")
.arg("ruchy")
.arg("run")
.arg(&temp_file)
.output()
.expect("Failed to run ruchy");
let _ = std::fs::remove_file(&temp_file);
assert!(
!output.status.success(),
"Command should timeout due to hang"
);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("Starting..."), "Should print before hang");
assert!(
!stdout.contains("Done!"),
"Should NOT reach after .output() call"
);
}
#[test]
#[ignore = "RED phase: Will hang indefinitely"]
fn test_runtime_090_03_command_output_in_function() {
let ruchy_script = r#"
use std::process::Command
fun check_command() -> bool {
println("Checking command...")
let result = Command::new("ls").output()
println("Command completed")
true
}
println("Starting...")
let success = check_command()
println("Done!")
"#;
let temp_file = std::env::temp_dir().join("test_command_function.ruchy");
std::fs::write(&temp_file, ruchy_script).unwrap();
let output = Command::new("timeout")
.arg("5")
.arg("ruchy")
.arg("run")
.arg(&temp_file)
.output()
.expect("Failed to run ruchy");
let _ = std::fs::remove_file(&temp_file);
assert!(
!output.status.success(),
"Command should timeout due to hang"
);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("Checking command..."),
"Should enter function"
);
assert!(
!stdout.contains("Command completed"),
"Should hang before completing"
);
}
#[test]
#[ignore = "RED phase: Will hang indefinitely"]
fn test_runtime_090_04_command_output_full_conversion() {
let ruchy_script = r#"
use std::process::Command
fun run_command(cmd: String, args: [String]) -> Result<String, String> {
println("Building command...")
let mut command = Command::new(cmd)
for arg in args {
command.arg(arg)
}
println("Executing...")
let output = command.output()
println("Processing result...")
Ok("success")
}
println("Starting system command...")
let result = run_command("ls", ["-la"])
println("Done!")
"#;
let temp_file = std::env::temp_dir().join("test_command_full.ruchy");
std::fs::write(&temp_file, ruchy_script).unwrap();
let output = Command::new("timeout")
.arg("5")
.arg("ruchy")
.arg("run")
.arg(&temp_file)
.output()
.expect("Failed to run ruchy");
let _ = std::fs::remove_file(&temp_file);
assert!(
!output.status.success(),
"Command should timeout due to hang"
);
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("Executing..."),
"Should reach .output() call"
);
assert!(
!stdout.contains("Processing result..."),
"Should hang at .output()"
);
}