|

test: always rebuild binaries in integration harness (avoid stale-artifact failures)

Author: Chris Tusa <chris.tusa@leafscale.com>
Date: Jun 13, 2026 18:32
Changeset: 9202641762f49e803e70ee9eb7fca6946a5697f8
Branch: default

Diff

diff -r 4cac1ef3af7d -r 9202641762f4 tests/integration/run_tests.sh
--- a/tests/integration/run_tests.sh	Sat Jun 13 17:30:15 2026 -0500
+++ b/tests/integration/run_tests.sh	Sat Jun 13 18:32:12 2026 -0500
@@ -8,9 +8,11 @@
 #
 # Usage: ./tests/integration/run_tests.sh
 #
-# Requirements:
-#   - zyginit built at build/zyginit
-#   - zygctl built at tools/zygctl/build/zygctl
+# Both binaries (zyginit + zygctl) are rebuilt from source at startup so the
+# tests always run against current code. Set ZYGINIT_TEST_NO_BUILD=1 to skip
+# the rebuild (fast iteration when you know the binaries are already current).
+#
+# Requirements (Linux dev): clang + reefc on PATH.
 #
 
 set -e
@@ -48,6 +50,31 @@
 TOTAL=0
 
 # ============================================================================
+# Build binaries
+# ============================================================================
+#
+# Always rebuild from source so the test binaries match current code. The
+# harness used to only build when a binary was MISSING, which let a stale
+# build/ artifact (e.g. an old version string) silently linger and fail tests.
+# Set ZYGINIT_TEST_NO_BUILD=1 to skip (e.g. fast local iteration).
+
+if [ -z "$ZYGINIT_TEST_NO_BUILD" ]; then
+    printf "Building zyginit + zygctl from source...\n"
+    mkdir -p "$PROJECT_DIR/build" "$PROJECT_DIR/tools/zygctl/build"
+    (
+        cd "$PROJECT_DIR" &&
+        clang -c src/helpers.c -o build/helpers.o &&
+        clang -c src/contract_linux_stubs.c -o build/contract_linux_stubs.o &&
+        reefc build --obj build/helpers.o --obj build/contract_linux_stubs.o
+    ) || { echo "ERROR: zyginit build failed"; exit 1; }
+    (
+        cd "$PROJECT_DIR/tools/zygctl" &&
+        clang -c src/symlink_wrapper.c -o build/symlink_wrapper.o &&
+        reefc build --obj build/symlink_wrapper.o
+    ) || { echo "ERROR: zygctl build failed"; exit 1; }
+fi
+
+# ============================================================================
 # Test framework
 # ============================================================================