diff options
| author | Scott Gasch <[email protected]> | 2026-08-29 19:27:16 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-08-29 19:27:16 -0700 |
| commit | 84a03824ed4cb78ee673d8c330c99557a5377923 (patch) | |
| tree | ffc2fab1827c3fe62b1500096a83dc8fd3f6ddda | |
| parent | 9632634b648109765955e89ec07f788388d8170f (diff) | |
Add precommit check helper script.
| -rwxr-xr-x | src/precommit_check.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/precommit_check.sh b/src/precommit_check.sh new file mode 100755 index 0000000..ccf0089 --- /dev/null +++ b/src/precommit_check.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Pre-commit build/test gate: TEST=1 self-test suite + 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/3] 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]" + +echo "=== [2/3] 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 "=== [3/3] 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" |
