ferrous-forge 1.9.3

System-wide Rust development standards enforcer
Documentation
//! Test runner for safety checks

use crate::Result;
use std::path::Path;

use super::{build, clippy, format, standards};

/// Run a quick test of the safety checks
///
/// # Errors
///
/// Returns an error if any safety check command fails to execute.
pub async fn test_safety_checks(project_path: &Path) -> Result<()> {
    println!("๐Ÿงช Testing Safety Pipeline Checks");
    println!("==================================");

    // Test format check
    println!("\n๐Ÿ“ Testing Format Check...");
    match format::run(project_path).await {
        Ok(result) => {
            println!(
                "  {} Format Check ({:.2}s)",
                result.status_emoji(),
                result.duration.as_secs_f64()
            );
            if !result.passed {
                for error in &result.errors {
                    println!("    โš ๏ธ  {}", error);
                }
            }
        }
        Err(e) => println!("  โŒ Format check error: {}", e),
    }

    // Test clippy check
    println!("\n๐Ÿ” Testing Clippy Check...");
    match clippy::run(project_path).await {
        Ok(result) => {
            println!(
                "  {} Clippy Check ({:.2}s)",
                result.status_emoji(),
                result.duration.as_secs_f64()
            );
            if !result.passed {
                for error in result.errors.iter().take(3) {
                    println!("    โš ๏ธ  {}", error);
                }
            }
        }
        Err(e) => println!("  โŒ Clippy check error: {}", e),
    }

    // Test build check
    println!("\n๐Ÿ—๏ธ  Testing Build Check...");
    match build::run(project_path).await {
        Ok(result) => {
            println!(
                "  {} Build Check ({:.2}s)",
                result.status_emoji(),
                result.duration.as_secs_f64()
            );
            if !result.passed {
                for error in result.errors.iter().take(2) {
                    println!("    โš ๏ธ  {}", error);
                }
            }
        }
        Err(e) => println!("  โŒ Build check error: {}", e),
    }

    // Test standards check
    println!("\n๐Ÿ“‹ Testing Standards Check...");
    match standards::run(project_path).await {
        Ok(result) => {
            println!(
                "  {} Standards Check ({:.2}s)",
                result.status_emoji(),
                result.duration.as_secs_f64()
            );
            if !result.passed {
                for error in result.errors.iter().take(3) {
                    println!("    โš ๏ธ  {}", error);
                }
            }
        }
        Err(e) => println!("  โŒ Standards check error: {}", e),
    }

    println!("\n๐ŸŽ‰ Safety pipeline test complete!");
    Ok(())
}