Repository navigation
Expand file tree
/
Copy pathtest
More file actions
executable file
·119 lines (111 loc) · 5.19 KB
/
Copy pathtest
File metadata and controls
executable file
·119 lines (111 loc) · 5.19 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
#!/usr/bin/env bash
# Run every test suite with this project's bin/ on PATH.
# Usage: ./test (FAST mode by default — quick, quiet on success)
# FAST= ./test (full statistical run)
# ./test fixed (run only suites whose name matches 'fixed')
# SUITE_TIMEOUT=60 ./test (override the per-suite wall-clock cap)
# Accumulates per-suite failures and returns the count as the exit code.
# NOTE: no `set -e` here on purpose. Suites deliberately exercise non-zero
# exit paths, and errexit would abort the runner on the first one.
set -u
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export PATH="$here/luajit:$PATH"
export RANDOM_TEST_FILE="$here/tests/random_test"
export FAST="${FAST-1}"
SUITE_TIMEOUT="${SUITE_TIMEOUT:-300}"
filter="${1-}"
failed=0
failed_suites=()
ran=0
# Required-suite manifest: the glob below is convenient for DISCOVERING
# suites, but a glob only ever reports what's still executable -- it has
# no concept of what SHOULD be there. `chmod -x tests/fixed_test
# tests/kernel_bc_sweep` demonstrated the gap directly: the glob (plus
# `[ -x "$suite" ] || continue` skipping non-executables) silently ran the
# remaining 4 suites and printed "All 4 suite(s) passed", exit 0 -- fewer
# tests ran, but nothing said so. Every suite name this project ships is
# listed here explicitly; missing OR non-executable is now a hard,
# named failure, not a quietly smaller passing count.
REQUIRED_SUITES=(benchmark_export_test kani_gate_test blake3_test drbg_test distribution_proof_test entropy_backend_test fixture_cleanup_test fixed_test geometric_library_test geometric_ffi_test geometric_lean_test geometric_rational_test unsigned_count_test golden_test help_test lean_independence_test lean_test luajit_cli_test luajit_library_test luajit_stream_test random_test random_jit_diff_test randoml_test randomr_architecture_test randomr_mutation_test randomr_test randomz_abi_test randomz_cross_compile_test randomz_test randomz_wasm_test release_strip_test state_test stream_test zig_package_test kernel_bc_sweep kernel_jit_diff zig_differential)
REQUIRED_SUITES+=(ziggurat_test ziggurat_production_test)
REQUIRED_SUITES+=(bend2_test bend2_proof_test)
REQUIRED_SUITES+=(bend2_benchmark_test)
REQUIRED_SUITES+=(bend2_ffi_test bend2_cli_test)
REQUIRED_SUITES+=(bend_full_benchmark_test)
REQUIRED_SUITES+=(stats_model_test build_arch_test)
if [ "$(uname -s)" = Linux ]; then
REQUIRED_SUITES+=(roc_core_test roc_platform_test roc_native_test roc_cli_test)
fi
missing=0
for name in "${REQUIRED_SUITES[@]}"; do
suite="$here/tests/$name"
if [ ! -e "$suite" ]; then
echo "REQUIRED SUITE MISSING: $name (expected at $suite)" >&2
missing=$((missing + 1))
elif [ ! -x "$suite" ]; then
echo "REQUIRED SUITE NOT EXECUTABLE: $name ($suite) -- chmod +x it" >&2
missing=$((missing + 1))
fi
done
if [ "$missing" -gt 0 ] && [ -z "$filter" ]; then
echo "" >&2
echo "$missing required suite(s) missing or non-executable -- refusing to report a passing run with fewer suites than expected" >&2
exit "$missing"
fi
# Build one current Roc snapshot for all default native/CLI/state/help checks.
# An explicitly selected installed package is tested without a local rebuild.
if [ -z "$filter" ] && [ "$(uname -s)" = Linux ]; then
root="$here"
source "$here/tests/roc_native_setup.sh"
roc_native_setup || exit 1
fi
# Reuse one source-verified Bend snapshot for the ABI, CLI and cross-language
# state/help gates. This experimental backend does not alter default commands.
if [ -z "$filter" ]; then
root="$here"
source "$here/tests/bend_native_setup.sh"
bend_native_setup || exit 1
fi
# Every suite runs under `timeout` -- a real, ordinary-arithmetic-reachable
# bug (M.exp's unbounded correction loop before it was bounded; see
# task-7-report.md's fix-up appendix) hung a suite forever with zero
# diagnostic output, which would have hung CI indefinitely rather than
# failing with a message. `timeout` converts that into a fast, loud,
# non-zero-exit failure every time, not just for exp -- any future hang in
# any suite gets the same treatment.
for suite in "$here"/tests/*_test "$here"/tests/kernel_bc_sweep "$here"/tests/kernel_jit_diff "$here"/tests/zig_differential; do
[ -x "$suite" ] || continue
name="$(basename "$suite")"
if [ -n "$filter" ] && [[ "$name" != *"$filter"* ]]; then continue; fi
ran=$((ran + 1))
# NOTE: deliberately NOT `if ! timeout ...; then rc=$?`. `!` inverts the
# exit status bash's `if` sees, and `$?` after entering the `then`
# branch reflects THAT inverted (already-negated-to-0) status, not
# timeout's real 124 -- confirmed directly: `if ! timeout 1 sleep 5;
# then rc=$?; fi` captures rc=0, not 124. Run bare, capture $? first,
# branch on it after.
timeout "$SUITE_TIMEOUT" "$suite"
rc=$?
if [ "$rc" -ne 0 ]; then
failed=$((failed + 1))
failed_suites+=("$name")
if [ "$rc" -eq 124 ]; then
echo "SUITE TIMED OUT after ${SUITE_TIMEOUT}s: $name" >&2
else
echo "SUITE FAILED: $name" >&2
fi
fi
done
if [ "$ran" -eq 0 ]; then
echo "No test suites matched '${filter}'" >&2
exit 1
fi
if [ "$failed" -gt 0 ]; then
echo "" >&2
printf 'Failed suites: %s\n' "${failed_suites[*]}" >&2
echo "$failed of $ran suite(s) FAILED" >&2
else
echo ""
echo "All $ran suite(s) passed"
fi
exit "$failed"