// TDD: RED Phase - Test that workspace builds and contains expected crates use std::process::Command; use std::path::Path; #[test] fn test_workspace_exists() { // Test that Cargo.toml exists at root assert!( Path::new("Cargo.toml").exists(), "Workspace Cargo.toml should exist at project root" ); } #[test] fn test_workspace_has_required_members() { // Read Cargo.toml and verify it has the required workspace members let cargo_content = std::fs::read_to_string("Cargo.toml") .expect("Should be able to read Cargo.toml"); // Verify workspace section exists assert!( cargo_content.contains("[workspace]"), "Cargo.toml should have [workspace] section" ); // Verify required crates are listed as members let required_crates = [ "rtx-compiler", "rtx-runtime", "rtx-kernel", "rtx-profiler", "rtx-bench", "rtx-governance", ]; for crate_name in &required_crates { assert!( cargo_content.contains(&format!("crates/{}", crate_name)), "Workspace should include crate: {}", crate_name ); } } #[test] fn test_workspace_builds_successfully() { // Test that cargo build works for the workspace let output = Command::new("cargo") .arg("build") .arg("--workspace") .output() .expect("Failed to execute cargo build"); assert!( output.status.success(), "Workspace should build successfully. Error: {}", String::from_utf8_lossy(&output.stderr) ); } #[test] fn test_rustg_dependency_configured() { // Test that rustg is configured as a workspace dependency let cargo_content = std::fs::read_to_string("Cargo.toml") .expect("Should be able to read Cargo.toml"); assert!( cargo_content.contains("[workspace.dependencies]"), "Should have workspace.dependencies section" ); assert!( cargo_content.contains("rustg"), "Should have rustg as a workspace dependency" ); } #[test] fn test_rust_toolchain_configured() { // Test that rust-toolchain.toml exists and specifies nightly let toolchain_path = Path::new("rust-toolchain.toml"); assert!( toolchain_path.exists(), "rust-toolchain.toml should exist" ); let toolchain_content = std::fs::read_to_string(toolchain_path) .expect("Should be able to read rust-toolchain.toml"); assert!( toolchain_content.contains("channel") && toolchain_content.contains("nightly"), "Should specify nightly channel" ); } #[test] fn test_each_crate_has_basic_structure() { let crates = [ "rtx-compiler", "rtx-runtime", "rtx-kernel", "rtx-profiler", "rtx-bench", "rtx-governance", ]; for crate_name in &crates { let crate_path = format!("crates/{}", crate_name); let cargo_path = format!("{}/Cargo.toml", crate_path); let lib_path = format!("{}/src/lib.rs", crate_path); assert!( Path::new(&cargo_path).exists(), "{} should have Cargo.toml", crate_name ); assert!( Path::new(&lib_path).exists(), "{} should have src/lib.rs", crate_name ); } }