#!/bin/bash # SamiOS test suite runner # Runs all test scripts and aggregates results. # # Usage: ./tests/run_tests.sh [--verbose] # Exit code: 0 if all tests pass, 1 if any fail. set -uo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" VERBOSE=false if [ "${1:-}" = "--verbose" ] || [ "${1:-}" = "-v" ]; then VERBOSE=true fi echo "╔══════════════════════════════════════╗" echo "║ SamiOS Test Suite Runner ║" echo "╚══════════════════════════════════════╝" TEST_FILES=( "test_profiledef.sh" "test_packages.sh" "test_pacman_conf.sh" "test_samios_cli.sh" "test_font_policy.sh" "test_version.sh" ) TOTAL_RUN=0 TOTAL_PASSED=0 TOTAL_FAILED=0 FAILED_SUITES=() for tf in "${TEST_FILES[@]}"; do full_path="$SCRIPT_DIR/$tf" if [ ! -f "$full_path" ]; then echo "WARNING: test file not found: $full_path" continue fi suite_name="${tf%.sh}" echo "" echo ">>> Running: $suite_name" # Run the test file in a subshell so we capture its exit code output=$(bash "$full_path" 2>&1) exit_code=$? if $VERBOSE || [ $exit_code -ne 0 ]; then echo "$output" else # Print just the suite headers and pass/fail lines echo "$output" | grep -E "^=|^ [✓✗]" fi if [ $exit_code -ne 0 ]; then FAILED_SUITES+=("$suite_name") echo " >>> FAILED" else echo " >>> PASSED" fi done # --------------------------------------------------------------------------- # Summary # --------------------------------------------------------------------------- echo "" echo "═══════════════════════════════════════" echo "SamiOS Test Suite — Final Summary" echo "═══════════════════════════════════════" if [ ${#FAILED_SUITES[@]} -eq 0 ]; then echo "All test suites PASSED ✓" exit 0 else echo "FAILED suites:" for s in "${FAILED_SUITES[@]}"; do echo " ✗ $s" done echo "" echo "${#FAILED_SUITES[@]} suite(s) failed" exit 1 fi