@@ -47,6 +47,10 @@ FAILED_TESTS_LIST="" |
| 47 | 47 | SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) |
| 48 | 48 | FORTSH_BIN="${FORTSH_BIN:-$SCRIPT_DIR/../../bin/fortsh}" |
| 49 | 49 | |
| 50 | +# Reference bash for expected output — must be bash 4+ for assoc arrays, case transforms |
| 51 | +# macOS ships bash 3.2 which lacks these; override with BASH_REF=/opt/homebrew/bin/bash |
| 52 | +BASH_REF="${BASH_REF:-bash}" |
| 53 | + |
| 50 | 54 | # Check if fortsh exists |
| 51 | 55 | if [ ! -x "$FORTSH_BIN" ]; then |
| 52 | 56 | printf "${RED}ERROR${NC}: fortsh binary not found at $FORTSH_BIN\n" |
@@ -101,7 +105,7 @@ TEST_TIMEOUT="${TEST_TIMEOUT:-10}" |
| 101 | 105 | # Helper: compare output against bash |
| 102 | 106 | compare_output() { |
| 103 | 107 | test_name="$1"; command="$2" |
| 104 | | - expected=$(run_with_timeout "$TEST_TIMEOUT" bash -c "$command" 2>&1) |
| 108 | + expected=$(run_with_timeout "$TEST_TIMEOUT" "$BASH_REF" -c "$command" 2>&1) |
| 105 | 109 | actual=$(run_with_timeout "$TEST_TIMEOUT" "$FORTSH_BIN" -c "$command" 2>&1) |
| 106 | 110 | norm_expected=$(normalize_shell_name "$expected") |
| 107 | 111 | norm_actual=$(normalize_shell_name "$actual") |
@@ -112,7 +116,7 @@ compare_output() { |
| 112 | 116 | # Helper: compare exit code only |
| 113 | 117 | compare_exit() { |
| 114 | 118 | test_name="$1"; command="$2" |
| 115 | | - run_with_timeout "$TEST_TIMEOUT" bash -c "$command" >/dev/null 2>&1; expected=$? |
| 119 | + run_with_timeout "$TEST_TIMEOUT" "$BASH_REF" -c "$command" >/dev/null 2>&1; expected=$? |
| 116 | 120 | run_with_timeout "$TEST_TIMEOUT" "$FORTSH_BIN" -c "$command" >/dev/null 2>&1; actual=$? |
| 117 | 121 | if [ "$expected" = "$actual" ]; then pass "$test_name" |
| 118 | 122 | else fail "$test_name" "exit $expected" "exit $actual"; fi |
@@ -121,7 +125,7 @@ compare_exit() { |
| 121 | 125 | # Helper: compare both output and exit code |
| 122 | 126 | compare_both() { |
| 123 | 127 | test_name="$1"; command="$2" |
| 124 | | - expected_out=$(run_with_timeout "$TEST_TIMEOUT" bash -c "$command" 2>&1); expected_exit=$? |
| 128 | + expected_out=$(run_with_timeout "$TEST_TIMEOUT" "$BASH_REF" -c "$command" 2>&1); expected_exit=$? |
| 125 | 129 | actual_out=$(run_with_timeout "$TEST_TIMEOUT" "$FORTSH_BIN" -c "$command" 2>&1); actual_exit=$? |
| 126 | 130 | norm_expected=$(normalize_shell_name "$expected_out") |
| 127 | 131 | norm_actual=$(normalize_shell_name "$actual_out") |