Bash · 2794 bytes Raw Blame History
1 #!/bin/sh
2 # =====================================
3 # POSIX Compliance Test Runner
4 # =====================================
5 # Runs all POSIX compliance test suites for shell
6 # Automatically detects fortsh binary location
7
8 set -e
9
10 # Colors
11 RED='\033[0;31m'
12 GREEN='\033[0;32m'
13 YELLOW='\033[1;33m'
14 BLUE='\033[0;34m'
15 CYAN='\033[0;36m'
16 NC='\033[0m'
17
18 # Get script directory
19 SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
20
21 # Require SHELL_BIN from environment (set by bensch entry point)
22 if [ -z "$SHELL_BIN" ] || [ ! -x "$SHELL_BIN" ]; then
23 printf "${RED}ERROR: SHELL_BIN not set or not executable${NC}\n"
24 printf "Run via: bensch --shell /path/to/shell --suite posix\n"
25 printf "Or set: export SHELL_BIN=/path/to/shell\n"
26 exit 1
27 fi
28
29 # Test suite files
30 TEST_SUITES="
31 posix_compliance_test.sh
32 posix_compliance_extended.sh
33 posix_compliance_builtins.sh
34 posix_compliance_advanced.sh
35 posix_compliance_gaps.sh
36 posix_compliance_jobcontrol.sh
37 posix_compliance_coverage.sh
38 posix_compliance_untested.sh
39 "
40
41 # Print header
42 printf "${CYAN}========================================\n"
43 printf "POSIX Compliance Test Suite Runner\n"
44 printf "========================================${NC}\n"
45 printf "fortsh binary: ${GREEN}%s${NC}\n" "$SHELL_BIN"
46 printf "Test directory: %s\n" "$SCRIPT_DIR"
47 printf "\n"
48
49 # Counters
50 TOTAL_SUITES=0
51 PASSED_SUITES=0
52 FAILED_SUITES=0
53 TOTAL_TESTS=0
54
55 # Run each test suite
56 for suite in $TEST_SUITES; do
57 suite_path="$SCRIPT_DIR/$suite"
58
59 if [ ! -f "$suite_path" ]; then
60 printf "${YELLOW}⊘ SKIP${NC}: %s (not found)\n" "$suite"
61 continue
62 fi
63
64 if [ ! -x "$suite_path" ]; then
65 printf "${YELLOW}⊘ SKIP${NC}: %s (not executable)\n" "$suite"
66 continue
67 fi
68
69 TOTAL_SUITES=$((TOTAL_SUITES + 1))
70
71 printf "${BLUE}========================================\n"
72 printf "Running: %s\n" "$suite"
73 printf "========================================${NC}\n"
74
75 # Run the test suite
76 if "$suite_path"; then
77 printf "${GREEN}✓ PASSED${NC}: %s\n\n" "$suite"
78 PASSED_SUITES=$((PASSED_SUITES + 1))
79 else
80 printf "${RED}✗ FAILED${NC}: %s\n\n" "$suite"
81 FAILED_SUITES=$((FAILED_SUITES + 1))
82 fi
83 done
84
85 # Print summary
86 printf "${CYAN}========================================\n"
87 printf "OVERALL SUMMARY\n"
88 printf "========================================${NC}\n"
89 printf "Total test suites: %d\n" "$TOTAL_SUITES"
90 printf "${GREEN}Passed suites: %d${NC}\n" "$PASSED_SUITES"
91 printf "${RED}Failed suites: %d${NC}\n" "$FAILED_SUITES"
92 printf "${CYAN}========================================${NC}\n"
93
94 if [ "$FAILED_SUITES" -eq 0 ] && [ "$TOTAL_SUITES" -gt 0 ]; then
95 printf "${GREEN}\n✓ ALL TEST SUITES PASSED!\n${NC}"
96 exit 0
97 else
98 printf "${RED}\n✗ SOME TEST SUITES FAILED\n${NC}"
99 exit 1
100 fi