@@ -40,6 +40,17 @@ set -euo pipefail
4040
4141SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
4242ZIG_DIR=" $( cd " $SCRIPT_DIR /.." && pwd) "
43+ ROOT_DIR=" $( cd " $ZIG_DIR /.." && pwd) "
44+
45+ # Helper function to check if the Rust/C oracle is available
46+ # Works on both macOS (.dylib) and Linux (.so)
47+ has_oracle () {
48+ [[ -f " $ROOT_DIR /lib/crsqlite.dylib" ]] || \
49+ [[ -f " $ROOT_DIR /lib/crsqlite-linux-x86_64.so" ]] || \
50+ [[ -f " $ROOT_DIR /lib/crsqlite-linux-aarch64.so" ]] || \
51+ [[ -f " $ROOT_DIR /lib/crsqlite-darwin-aarch64.dylib" ]] || \
52+ [[ -f " $ROOT_DIR /lib/crsqlite-darwin-x86_64.dylib" ]]
53+ }
4354
4455echo " ╔═══════════════════════════════════════════════════════════════════════╗"
4556echo " ║ Zig CR-SQLite Parity Test Suite ║"
503514
504515# Run fract parity tests (oracle comparison: Zig vs Rust/C)
505516echo " Running test-fract-parity.sh..."
506- if [[ -f " $ROOT_DIR /lib/crsqlite.dylib " ]] 2> /dev/null || ROOT_DIR= " $( cd " $ZIG_DIR /.. " && pwd ) " && [[ -f " $ROOT_DIR /lib/crsqlite.dylib " ]] ; then
517+ if has_oracle ; then
507518 if bash " $SCRIPT_DIR /test-fract-parity.sh" > " $TMPFILE " 2>&1 ; then
508519 FRACT_PARITY_PASS=$( grep -c " PASS" " $TMPFILE " 2> /dev/null) || FRACT_PARITY_PASS=0
509520 echo " Fract parity tests: $FRACT_PARITY_PASS passed"
543554
544555# Run API surface parity test (oracle comparison vs Rust/C)
545556echo " Running test-api-surface.sh..."
546- ROOT_DIR=" $( cd " $ZIG_DIR /.." && pwd) "
547- if [[ -f " $ROOT_DIR /lib/crsqlite.dylib" ]]; then
557+ if has_oracle; then
548558 # Export extension paths using the freshly built Zig extension
549559 export ZIG_EXT_PATH=" $EXT "
550560 if bash " $SCRIPT_DIR /test-api-surface.sh" > " $TMPFILE " 2>&1 ; then
@@ -560,13 +570,13 @@ if [[ -f "$ROOT_DIR/lib/crsqlite.dylib" ]]; then
560570 # Note: gaps are tracked but don't fail the suite - they're expected during development
561571 fi
562572else
563- echo " API surface tests: SKIPPED (Rust/C extension not found at $ROOT_DIR /lib/crsqlite.dylib )"
573+ echo " API surface tests: SKIPPED (Rust/C extension not found)"
564574 TOTAL_SKIP=$(( TOTAL_SKIP + 2 ))
565575fi
566576
567577# Run db_version parity tests (oracle comparison: Zig vs Rust/C)
568578echo " Running test-db-version-parity.sh..."
569- if [[ -f " $ROOT_DIR /lib/crsqlite.dylib " ]] ; then
579+ if has_oracle ; then
570580 if bash " $SCRIPT_DIR /test-db-version-parity.sh" > " $TMPFILE " 2>&1 ; then
571581 DBVER_PASS=$( grep -c " PASS:" " $TMPFILE " 2> /dev/null) || DBVER_PASS=0
572582 echo " db_version parity tests: $DBVER_PASS passed"
592602
593603# Run rows_impacted parity tests (oracle comparison: Zig vs Rust/C counter reset timing)
594604echo " Running test-rows-impacted-parity.sh..."
595- if [[ -f " $ROOT_DIR /lib/crsqlite.dylib " ]] ; then
605+ if has_oracle ; then
596606 if bash " $SCRIPT_DIR /test-rows-impacted-parity.sh" > " $TMPFILE " 2>&1 ; then
597607 ROWS_PASS=$( grep -c " PASS:" " $TMPFILE " 2> /dev/null) || ROWS_PASS=0
598608 echo " rows_impacted parity tests: $ROWS_PASS passed"
0 commit comments