[go: up one dir, main page]

coreutils 0.5.0

coreutils ~ GNU coreutils (updated); implemented as universal (cross-platform) utils, written in Rust
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...");
    
    // Create a simple test file
    std::fs::write("test_input.txt", "Hello, World!").unwrap();
    
    // Test 1: Run base64 with stdout piped
    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");
    
    // Wait for a short time to see if it completes
    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();
        }
    }
    
    // Test 2: Run base64 with stdout inherited (normal)
    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);
    
    // Clean up
    std::fs::remove_file("test_input.txt").ok();
}