msvc 0.1.0

A tool to automate setup for MSVC projects with vc-ltl and thunk-rs.
use std::process::Command;
use tempfile::TempDir;
use std::fs;

#[test]
#[cfg(target_env = "msvc")]
fn test_cargo_msvc_integration_without_thunk() {
    // Create a temporary directory for our test project
    let temp_dir = TempDir::new().unwrap();
    let project_path = temp_dir.path().join("test_project");

    // Create a new Cargo project in the temporary directory
    let output = Command::new("cargo")
        .args(&["new", "--bin", "test_project"])
        .current_dir(temp_dir.path())
        .output()
        .expect("Failed to create test project");

    assert!(output.status.success(), "Failed to create test project: {}", String::from_utf8_lossy(&output.stderr));

    // Get the path to our cargo-msvc binary
    let cargo_msvc_path = std::env::var("CARGO_BIN_EXE_cargo-msvc")
        .expect("CARGO_BIN_EXE_cargo-msvc not set")
        .to_string();

    // Run cargo-msvc (without any flags) in the test project directory
    let output = Command::new(&cargo_msvc_path)
        .current_dir(&project_path)
        .output()
        .expect("Failed to run cargo-msvc");

    // Print stdout and stderr for debugging
    println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
    println!("stderr: {}", String::from_utf8_lossy(&output.stderr));

    // Assert that the command was successful
    assert!(output.status.success(), "cargo-msvc failed");

    // Check that vc-ltl was added to Cargo.toml
    let cargo_toml_content = fs::read_to_string(project_path.join("Cargo.toml")).unwrap();
    assert!(cargo_toml_content.contains("vc-ltl"), "vc-ltl not found in Cargo.toml");

    // Run cargo-msvc again to remove vc-ltl
    let output2 = Command::new(&cargo_msvc_path)
        .current_dir(&project_path)
        .output()
        .expect("Failed to run cargo-msvc");

    // Assert that the command was successful
    assert!(output2.status.success(), "cargo-msvc failed");

    // Check that vc-ltl was removed from Cargo.toml
    let cargo_toml_content2 = fs::read_to_string(project_path.join("Cargo.toml")).unwrap();
    assert!(!cargo_toml_content2.contains("vc-ltl"), "vc-ltl should have been removed from Cargo.toml");
}