blob: 05257653fb34b37ae3cc1348027e72c26afadd7a (
plain)
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
|
#!/bin/sh
# Pre-commit build/test gate: TEST=1 self-test suite + a combined
# DEBUG=1 TEST=1 self-test (asserts live) + DEBUG=1 random-sample
# smoke test (debug_smoke_test.sh). Restores a normal release build
# afterward so the working directory isn't left with a TEST/DEBUG-flavored
# binary as a side effect of running this.
#
# NOT wired as an automatic git hook by default -- see CLAUDE.md's
# "Pre-commit testing" section for why (rebuild time, binary-clobbering
# risk if something else is using ./typhoon or ./_typhoon). Run by hand:
# ./precommit_check.sh
cd "$(dirname "$0")" || exit 1
LOGDIR=/tmp/typhoon/precommit
mkdir -p "$LOGDIR"
FAIL=0
TOTAL_START=$(date +%s)
echo "=== [1/4] Self-test build (gmake TEST=1) ==="
STEP_START=$(date +%s)
gmake clean > "$LOGDIR/clean_test.log" 2>&1
gmake -j5 TEST=1 GENETIC=1 SIXTYFOUR=1 > "$LOGDIR/build_test.log" 2>&1
if [ $? -ne 0 ]; then
echo " BUILD FAILED -- see $LOGDIR/build_test.log"
FAIL=1
else
./typhoon --batch --command "" > "$LOGDIR/test_run.log" 2>&1
STATUS=$?
if [ "$STATUS" -ne 0 ] || grep -qi "assertion failure" "$LOGDIR/test_run.log"; then
echo " SELF-TEST FAILED (exit=$STATUS) -- see $LOGDIR/test_run.log"
FAIL=1
else
echo " self-test passed"
fi
fi
STEP_END=$(date +%s)
echo " [$((STEP_END - STEP_START))s]"
# 2026-10-15: added after combining DEBUG=1 and TEST=1 for the first
# time (ever, as far as anyone could tell) turned up three real,
# previously-undiscovered bugs in a single run -- none in production
# code, all in self-test-only harnesses whose assert-guarded invariants
# had apparently never been checked with asserts actually compiled in
# (plain TEST=1 has no DEBUG, so ASSERT is a no-op; DEBUG=1 alone never
# links the self-test .o files at all). Unoptimized, so this step is
# the slow one -- budget a couple of minutes, not seconds.
echo "=== [2/4] Combined self-test build (gmake DEBUG=1 TEST=1) ==="
STEP_START=$(date +%s)
gmake clean > "$LOGDIR/clean_debugtest.log" 2>&1
gmake -j5 DEBUG=1 TEST=1 GENETIC=1 > "$LOGDIR/build_debugtest.log" 2>&1
if [ $? -ne 0 ]; then
echo " BUILD FAILED -- see $LOGDIR/build_debugtest.log"
FAIL=1
else
./_typhoon --batch --command "" > "$LOGDIR/test_run_debugtest.log" 2>&1
STATUS=$?
if [ "$STATUS" -ne 0 ] || grep -qi "assertion failure\|PANIC" "$LOGDIR/test_run_debugtest.log"; then
echo " SELF-TEST FAILED (exit=$STATUS) -- see $LOGDIR/test_run_debugtest.log"
FAIL=1
else
echo " self-test passed"
fi
fi
STEP_END=$(date +%s)
echo " [$((STEP_END - STEP_START))s]"
echo "=== [3/4] DEBUG smoke test (10 random ECM positions, sd 4) ==="
STEP_START=$(date +%s)
gmake clean > "$LOGDIR/clean_debug.log" 2>&1
gmake -j5 GENETIC=1 DEBUG=1 MP=1 SIXTYFOUR=1 > "$LOGDIR/build_debug.log" 2>&1
if [ $? -ne 0 ]; then
echo " BUILD FAILED -- see $LOGDIR/build_debug.log"
FAIL=1
else
./debug_smoke_test.sh ./_typhoon 4 10
[ $? -ne 0 ] && FAIL=1
fi
STEP_END=$(date +%s)
echo " [$((STEP_END - STEP_START))s]"
echo "=== [4/4] Restoring normal release build (GENETIC=1 PERF_COUNTERS=1 MP=1 SIXTYFOUR=1) ==="
STEP_START=$(date +%s)
gmake clean > "$LOGDIR/clean_release.log" 2>&1
gmake -j5 GENETIC=1 PERF_COUNTERS=1 MP=1 SIXTYFOUR=1 > "$LOGDIR/build_release.log" 2>&1
if [ $? -ne 0 ]; then
echo " BUILD FAILED -- see $LOGDIR/build_release.log"
FAIL=1
fi
STEP_END=$(date +%s)
echo " [$((STEP_END - STEP_START))s]"
TOTAL_END=$(date +%s)
echo
echo "Total: $((TOTAL_END - TOTAL_START))s"
if [ "$FAIL" -ne 0 ]; then
echo "PRE-COMMIT CHECK FAILED"
exit 1
fi
echo "PRE-COMMIT CHECK PASSED"
echo "git commit"
echo "./update_head_reference.sh"
|