Repository navigation
Expand file tree
/
Copy pathrun_all_tests.sh
More file actions
executable file
·188 lines (155 loc) · 5.65 KB
/
Copy pathrun_all_tests.sh
File metadata and controls
executable file
·188 lines (155 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env bash
set -u
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
export PYTHONPATH="$ROOT_DIR${PYTHONPATH:+:$PYTHONPATH}"
TOTAL_CHECKS=0
FAILED_CHECKS=0
SKIPPED_CHECKS=0
# Kill switch: per-check timeout plus check selection.
# A7_CHECK_TIMEOUT (seconds, default 3600, 0 disables) bounds each check so a
# hung suite fails fast instead of hanging the gate. --timeout SECS overrides
# it. --only SUB (repeatable) runs only matching checks. --skip SUB
# (repeatable) skips matching checks. Match is a case-insensitive substring
# of the check title.
CHECK_TIMEOUT="${A7_CHECK_TIMEOUT:-3600}"
PYTEST_WORKERS="${A7_PYTEST_WORKERS-8}"
ONLY_FILTERS=()
SKIP_FILTERS=()
usage() {
echo "Usage: $0 [--timeout SECS] [--only SUB]... [--skip SUB]..."
echo " A7_CHECK_TIMEOUT env sets the default per-check timeout (0 disables)."
echo " A7_PYTEST_WORKERS env sets pytest workers (1..8, default 8)."
}
# Every flag that takes a value fails loudly without one, and an unknown
# argument is an error: a typo must not turn into a green run.
need_value() {
if (( $# < 2 )); then
echo "error: $1 needs a value" >&2
usage >&2
exit 2
fi
}
while (( $# > 0 )); do
case "$1" in
--timeout=*) CHECK_TIMEOUT="${1#--timeout=}"; shift ;;
--timeout) need_value "$@"; CHECK_TIMEOUT="$2"; shift 2 ;;
--only=*) ONLY_FILTERS+=("${1#--only=}"); shift ;;
--only) need_value "$@"; ONLY_FILTERS+=("$2"); shift 2 ;;
--skip=*) SKIP_FILTERS+=("${1#--skip=}"); shift ;;
--skip) need_value "$@"; SKIP_FILTERS+=("$2"); shift 2 ;;
--help|-h) usage; exit 0 ;;
*)
echo "error: unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
done
if ! [[ "$CHECK_TIMEOUT" =~ ^[0-9]+$ ]]; then
echo "error: timeout must be a whole number of seconds, got '$CHECK_TIMEOUT'" >&2
exit 2
fi
if ! [[ "$PYTEST_WORKERS" =~ ^[1-8]$ ]]; then
echo "error: A7_PYTEST_WORKERS must be an integer from 1 to 8, got '$PYTEST_WORKERS'" >&2
exit 2
fi
should_run() {
local title="$1"
local lower
lower="$(printf '%s' "$title" | tr '[:upper:]' '[:lower:]')"
local f
if (( ${#ONLY_FILTERS[@]} > 0 )); then
local hit=0
for f in "${ONLY_FILTERS[@]}"; do
case "$lower" in
*"$(printf '%s' "$f" | tr '[:upper:]' '[:lower:]')"*) hit=1; break ;;
esac
done
(( hit == 0 )) && return 1
fi
for f in "${SKIP_FILTERS[@]}"; do
case "$lower" in
*"$(printf '%s' "$f" | tr '[:upper:]' '[:lower:]')"*) return 1 ;;
esac
done
return 0
}
run_check() {
local title="$1"
shift
if ! should_run "$title"; then
SKIPPED_CHECKS=$((SKIPPED_CHECKS + 1))
echo "$title"
printf 'SKIP: filter\n\n'
return 0
fi
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
echo "$title"
local output
local status
if (( CHECK_TIMEOUT > 0 )) && command -v timeout >/dev/null 2>&1; then
output="$(timeout --signal=TERM --kill-after=60 "$CHECK_TIMEOUT" "$@" 2>&1)"
status=$?
if (( status == 124 )); then
printf 'FAIL: TIMEOUT after %ss (A7_CHECK_TIMEOUT/--timeout kill switch)\n\n' "$CHECK_TIMEOUT"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 0
fi
else
output="$("$@" 2>&1)"
status=$?
fi
local summary
summary="$(printf '%s\n' "$output" | tail -n 1)"
if [[ -z "$summary" ]]; then
summary="(no output)"
fi
if (( status == 0 )); then
printf 'PASS: %s\n\n' "$summary"
return 0
fi
printf 'FAIL: %s\n' "$summary"
echo "---- recent output ----"
printf '%s\n' "$output" | tail -n 20
echo "-----------------------"
echo ""
FAILED_CHECKS=$((FAILED_CHECKS + 1))
return 0
}
echo "============================================================"
echo "A7 COMPILER - COMPLETE TEST RESULTS"
echo "============================================================"
echo ""
run_check "All Pytest Tests:" \
uv run pytest --tb=short -q -n "$PYTEST_WORKERS"
run_check "Examples E2E Verification (compile/build/run/output):" \
uv run python scripts/verify_examples_e2e.py
run_check "Debug Artifact Build Verification (Zig):" \
uv run python scripts/build_examples.py --profile debug --backend zig --clean
run_check "Release Artifact Build Verification (Zig):" \
uv run python scripts/build_examples.py --profile release --backend zig --clean
run_check "Fast Artifact Build Verification (Zig):" \
uv run python scripts/build_examples.py --profile fast --backend zig --clean
run_check "Bench Perf (timing ratios report-only):" \
uv run python scripts/bench_perf.py
run_check "Error Stage Verification (mode/format matrix):" \
uv run python scripts/verify_error_stages.py --mode-set all --format both
run_check "Docs Style Check:" \
uv run python scripts/check_docs_style.py
run_check "Secrets Check:" \
uv run python scripts/check_no_secrets.py
run_check "Package Build:" \
bash -lc 'rm -rf dist && uv build'
run_check "Wheel and Source Distribution Native Verification:" \
uv run python scripts/verify_wheel_install.py --skip-build --verify-sdist
PASSED_CHECKS=$((TOTAL_CHECKS - FAILED_CHECKS))
echo "============================================================"
echo "Summary: ${PASSED_CHECKS}/${TOTAL_CHECKS} checks passed (${SKIPPED_CHECKS} skipped, timeout ${CHECK_TIMEOUT}s, 124 means kill switch fired)"
if (( TOTAL_CHECKS == 0 )); then
echo "error: no check ran; --only/--skip matched nothing to run" >&2
exit 2
fi
if (( FAILED_CHECKS > 0 )); then
exit 1
fi