#!/bin/bash ################################################################################ # run-all-tests-comprehensive.sh # Enhanced comprehensive test runner for ROM Groomer project # # Runs all test suites including: # - Original tests (build scripts, setup, utilities) # - New comprehensive tests (converters, organizers, error handling) # - Performance and edge case tests ################################################################################ # Get the directory of the current script SCRIPT_DIR="$(dirname "$(realpath "$0")")" # Determine the project root directory PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' # No Color # Track overall results TOTAL_SUITES=0 PASSED_SUITES=0 FAILED_SUITES=0 SKIPPED_SUITES=0 echo -e "${CYAN}========================================================================" echo -e " ROM GROOMER COMPREHENSIVE TEST SUITE" echo -e " Enhanced Test Runner" echo -e "========================================================================${NC}" echo "" # Function to run a test suite run_test_suite() { local suite_name="$1" local test_script="$2" local description="$3" echo -e "${BLUE}=========================================" echo -e "Running: $suite_name" echo -e "=========================================${NC}" if [ -n "$description" ]; then echo -e "${CYAN}$description${NC}" echo "" fi TOTAL_SUITES=$((TOTAL_SUITES + 1)) if [ ! -f "$test_script" ]; then echo -e "${YELLOW}⚠ Test suite not found or not executable: $(basename "$test_script")${NC}" SKIPPED_SUITES=$((SKIPPED_SUITES + 1)) echo "" return 1 fi # Run the test with timeout to prevent hanging local start_time=$(date +%s) if timeout 300s bash "$test_script"; then local end_time=$(date +%s) local duration=$((end_time - start_time)) PASSED_SUITES=$((PASSED_SUITES + 1)) echo -e "${GREEN}✅ $suite_name: PASSED (${duration}s)${NC}" else local exit_code=$? local end_time=$(date +%s) local duration=$((end_time - start_time)) FAILED_SUITES=$((FAILED_SUITES + 1)) if [ $exit_code -eq 124 ]; then echo -e "${RED}❌ $suite_name: TIMEOUT after 5 minutes${NC}" else echo -e "${RED}❌ $suite_name: FAILED (${duration}s)${NC}" fi fi echo "" } # Run existing core test suites echo -e "${CYAN}=== CORE SYSTEM VALIDATION ===${NC}" echo "" run_test_suite "Build Script Naming Standards" \ "${SCRIPT_DIR}/test-build-script-naming.sh" \ "Validates build script naming conventions and standards compliance" run_test_suite "Build Script Content Validation" \ "${SCRIPT_DIR}/test-build-script-content.sh" \ "Validates build script content, headers, and required functions" run_test_suite "Specific Fixes Validation" \ "${SCRIPT_DIR}/test-specific-fixes.sh" \ "Validates specific fixes applied to build scripts and configurations" echo -e "${CYAN}=== SYSTEM SETUP AND UTILITIES ===${NC}" echo "" run_test_suite "Setup Wizard" \ "${SCRIPT_DIR}/test-setup-wizard.sh" \ "Tests interactive setup wizard functionality and configuration generation" run_test_suite "Enhanced Utilities" \ "${SCRIPT_DIR}/test-utils.sh" \ "Tests core utility functions including file operations and path validation" run_test_suite "Pre-flight Checks" \ "${SCRIPT_DIR}/test-preflight-checks.sh" \ "Tests system dependency checking and pre-flight validation" echo -e "${CYAN}=== INTEGRATION AND WORKFLOW ===${NC}" echo "" run_test_suite "Integration Workflow" \ "${SCRIPT_DIR}/test-integration.sh" \ "Tests end-to-end workflow integration and process chaining" echo -e "${CYAN}=== CORE FUNCTIONALITY TESTS ===${NC}" echo "" run_test_suite "Converter Tests" \ "${SCRIPT_DIR}/test-converters.sh" \ "Comprehensive tests for ROM conversion scripts (ZIP to OGG/CUE, FLAC, CHD)" run_test_suite "Organizer Tests" \ "${SCRIPT_DIR}/test-organizers.sh" \ "Comprehensive tests for ROM organization and sorting functionality" echo -e "${CYAN}=== RELIABILITY AND ROBUSTNESS ===${NC}" echo "" run_test_suite "Error Handling Tests" \ "${SCRIPT_DIR}/test-error-handling.sh" \ "Tests error conditions, edge cases, and graceful failure handling" # Run any additional specific tests echo -e "${CYAN}=== SPECIFIC COMPONENT TESTS ===${NC}" echo "" run_test_suite "Delete List Files" \ "${SCRIPT_DIR}/test-delete-listfiles.sh" \ "Tests list-based file deletion functionality" run_test_suite "Organize ROMs" \ "${SCRIPT_DIR}/test-organize-roms.sh" \ "Tests ROM organization by system and region" run_test_suite "Sort to Folders" \ "${SCRIPT_DIR}/test-sort2folders.sh" \ "Tests folder-based sorting and organization" run_test_suite "Unzip Files" \ "${SCRIPT_DIR}/test-unzipfiles.sh" \ "Tests ZIP file extraction and processing" # Calculate results echo -e "${CYAN}==========================================================================" echo -e " COMPREHENSIVE SUMMARY" echo -e "==========================================================================${NC}" echo "" echo -e "${CYAN}Test Suite Results:${NC}" suite_number=1 for suite in \ "Build Script Naming Standards" \ "Build Script Content Validation" \ "Specific Fixes Validation" \ "Setup Wizard" \ "Enhanced Utilities" \ "Pre-flight Checks" \ "Integration Workflow" \ "Converter Tests" \ "Organizer Tests" \ "Error Handling Tests"; do echo -e " ${suite_number}. ${suite}" suite_number=$((suite_number + 1)) done echo "" echo -e "${CYAN}Overall Statistics:${NC}" echo -e " Total Test Suites: ${TOTAL_SUITES}" echo -e " ${GREEN}Passed: ${PASSED_SUITES}${NC}" echo -e " ${RED}Failed: ${FAILED_SUITES}${NC}" echo -e " ${YELLOW}Skipped: ${SKIPPED_SUITES}${NC}" echo "" # Calculate percentages if [ $TOTAL_SUITES -gt 0 ]; then pass_percentage=$(( (PASSED_SUITES * 100) / TOTAL_SUITES )) fail_percentage=$(( (FAILED_SUITES * 100) / TOTAL_SUITES )) skip_percentage=$(( (SKIPPED_SUITES * 100) / TOTAL_SUITES )) echo -e "${CYAN}Test Coverage:${NC}" echo -e " ${GREEN}Pass Rate: ${pass_percentage}%${NC}" echo -e " ${RED}Failure Rate: ${fail_percentage}%${NC}" echo -e " ${YELLOW}Skip Rate: ${skip_percentage}%${NC}" echo "" fi # Overall assessment if [ $FAILED_SUITES -eq 0 ]; then if [ $SKIPPED_SUITES -eq 0 ]; then echo -e "${GREEN}🎉 ALL TESTS PASSED! The ROM groomer system is fully compliant.${NC}" echo "" echo -e "${GREEN}System Health: ✅ EXCELLENT${NC}" echo -e "${GREEN}Standards Compliance: ✅ FULL${NC}" echo -e "${GREEN}Build Script Quality: ✅ VALIDATED${NC}" echo -e "${GREEN}Error Handling: ✅ ROBUST${NC}" echo -e "${GREEN}Converter Functionality: ✅ TESTED${NC}" echo -e "${GREEN}Organization Features: ✅ VERIFIED${NC}" else echo -e "${YELLOW}✓ All available tests passed, but some tests were skipped.${NC}" echo "" echo -e "${YELLOW}System Health: ⚠ GOOD (some features not tested)${NC}" echo -e "${GREEN}Standards Compliance: ✅ FULL${NC}" fi exit 0 else echo -e "${RED}❌ Some tests failed. Please review the failures above.${NC}" echo "" echo -e "${RED}System Health: ⚠ NEEDS ATTENTION${NC}" echo -e "${RED}Failed Tests: ${FAILED_SUITES}${NC}" if [ $PASSED_SUITES -gt 0 ]; then echo -e "${GREEN}Working Features: ${PASSED_SUITES} test suites passed${NC}" fi exit 1 fi