- Created run-all-tests.sh to execute test suite in sequence - Fail-fast approach stops on first failure (TDD RED phase) - Provides summary and next steps (final verification) - Can be run from any directory (uses absolute paths) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
1.9 KiB
Bash
Executable File
74 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test Suite Runner: Lab 01 - IAM & Sicurezza
|
|
# Runs all tests in sequence and provides summary
|
|
# Usage: bash labs/lab-01-iam/tests/run-all-tests.sh
|
|
|
|
set -euo pipefail
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$TEST_DIR/../.." && pwd)"
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo -e "${BLUE}Lab 01 Test Suite${NC}"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo ""
|
|
|
|
# Array of test files in order
|
|
declare -a tests=(
|
|
"$TEST_DIR/test-01-user-creation.sh"
|
|
"$TEST_DIR/test-02-docker-access.sh"
|
|
"$TEST_DIR/03-non-root-test.sh"
|
|
)
|
|
|
|
total_tests=${#tests[@]}
|
|
passed_tests=0
|
|
failed_tests=0
|
|
|
|
for i in "${!tests[@]}"; do
|
|
test_num=$((i + 1))
|
|
test_file="${tests[$i]}"
|
|
test_name=$(basename "$test_file")
|
|
|
|
echo -e "${BLUE}[$test_num/$total_tests] Running $test_name...${NC}"
|
|
|
|
if bash "$test_file"; then
|
|
echo -e "${GREEN}✓ PASSED${NC}"
|
|
echo ""
|
|
((passed_tests++)) || true
|
|
else
|
|
echo -e "${RED}✗ FAILED${NC}"
|
|
echo ""
|
|
((failed_tests++)) || true
|
|
# Fail-fast: stop on first failure
|
|
break
|
|
fi
|
|
done
|
|
|
|
# Summary
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo -e "${BLUE}Test Suite Summary${NC}"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
echo "Passed: $passed_tests/$total_tests"
|
|
echo "Failed: $failed_tests/$total_tests"
|
|
echo ""
|
|
|
|
if [ $failed_tests -eq 0 ]; then
|
|
echo -e "${GREEN}All tests passed!${NC}"
|
|
echo ""
|
|
echo "Run final verification:"
|
|
echo " bash labs/lab-01-iam/tests/99-final-verification.sh"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
exit 0
|
|
else
|
|
echo -e "${RED}Some tests failed${NC}"
|
|
echo -e "${BLUE}========================================${NC}"
|
|
exit 1
|
|
fi
|