The amalgamation and the bindings now ship with sx itself (sx library/vendors/sqlite/ — bindings + c/ amalgamation); every import flips from ../src/db/sqlite.sx to vendors/sqlite/sqlite.sx, resolved through the compiler's stdlib search paths. vendor/ and src/db/ leave this repo entirely. make test 22/22 — the object cache keys on content, not path, so the relocated source still hits the existing cache entries.
47 lines
1.5 KiB
Bash
Executable File
47 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Test runner — discovers every tests/**/*.sx, runs each via `$SX run`, and
|
|
# reports per-test ok/FAIL. Exits 0 only when every test passes.
|
|
#
|
|
# A test passes iff `$SX run <file>` exits 0 (compile failures count as a
|
|
# failure too). Each test program asserts its own invariants — e.g. via
|
|
# process.assert — and exits non-zero on failure.
|
|
#
|
|
# Locate the compiler via SX (overridable); defaults to the sibling sx repo.
|
|
#
|
|
# SQLite needs no flags here: the sx library ships it (vendors/sqlite),
|
|
# declared as a `#import c` unit — `sx run` compiles (cached) and loads it
|
|
# as a priority symbol target; the version assert in tests/sqlite_smoke.sx
|
|
# proves the OS copy never shadows it.
|
|
set -u
|
|
|
|
SX="${SX:-/Users/agra/projects/sx/zig-out/bin/sx}"
|
|
TESTS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
|
|
pass=0
|
|
fail=0
|
|
|
|
# Test filenames follow the no-spaces convention, so word-splitting the
|
|
# sorted find output is safe and keeps the loop in the current shell (so the
|
|
# pass/fail counters survive).
|
|
for t in $(find "$TESTS_DIR" -name '*.sx' -type f | sort); do
|
|
name=${t#"$TESTS_DIR"/}
|
|
if "$SX" run "$t" >/dev/null 2>&1; then
|
|
printf ' %-44s ok\n' "$name"
|
|
pass=$((pass + 1))
|
|
else
|
|
printf ' %-44s FAIL\n' "$name"
|
|
fail=$((fail + 1))
|
|
fi
|
|
done
|
|
|
|
total=$((pass + fail))
|
|
if [ "$total" -eq 0 ]; then
|
|
echo "no tests found under $TESTS_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "------------------------------------------------"
|
|
printf 'tests: %d pass: %d fail: %d\n' "$total" "$pass" "$fail"
|
|
|
|
[ "$fail" -eq 0 ]
|