use std::io::{self, Write};
use std::process::{Command, Stdio};
use std::thread;
use std::time::Duration;
fn main() {
println!("Testing if base64 hangs when stdout is captured...");
std::fs::write("test_input.txt", "Hello, World!").unwrap();
println!("Test 1: Running base64 with piped stdout");
let mut child = Command::new("target/release/base64")
.arg("test_input.txt")
.stdout(Stdio::piped())
.spawn()
.expect("Failed to spawn base64");
match child.wait_timeout(Duration::from_secs(2)).unwrap() {
Some(status) => println!("Base64 completed with status: {:?}", status),
None => {
println!("Base64 appears to hang with piped stdout!");
child.kill().unwrap();
}
}
println!("\nTest 2: Running base64 with inherited stdout");
let status = Command::new("target/release/base64")
.arg("test_input.txt")
.status()
.expect("Failed to run base64");
println!("Base64 completed with status: {:?}", status);
std::fs::remove_file("test_input.txt").ok();
}