mirror of
https://github.com/zap-proto/lua.git
synced 2026-10-30 15:04:38 +00:00
- .github/workflows/ci.yml: push-to-main + PR + workflow_dispatch. Installs luajit + luarocks + lunitx + capnproto on ubuntu-latest, loads the module, runs the full suite. Validated end-to-end in ubuntu:22.04 (capnp 0.8.0): 59 tests / 504 assertions, 0 failures, 0 skips. - tools/gen-example.sh: single canonical path to generate proto/example_zap.lua from proto/*.zap using the capnp front-end + this repo's pure-Lua compiler. Makes tests 01 and 10 run for real instead of skipping when no 'zap' tool. - tests/run_tests.sh: generate the fixture via tools/gen-example.sh; honest skip only when capnp is genuinely absent. - bin/zapc-lua: make cjson optional (pcall) to match bin/zapc-llua; it is only used for the --verbose debug dump and is not required to run.
43 lines
1.2 KiB
Bash
Executable File
43 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Run the lua-zap unit tests.
|
|
#
|
|
# Tests 02 (util) and 03 (compile) are pure-Lua and always run.
|
|
# Tests 01 (sanity) and 10 (encode-decode) need the generated module
|
|
# proto/example_zap.lua, produced from proto/*.zap by tools/gen-example.sh
|
|
# (capnp front-end + this repo's pure-Lua compiler). If capnp is unavailable we
|
|
# skip those two with a note rather than report a false pass.
|
|
|
|
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
|
export LUA_PATH="$ROOT/?.lua;$ROOT/lua/?.lua;$ROOT/proto/?.lua;$ROOT/tests/?.lua;$ROOT/vendor/?.lua;$LUA_PATH;;"
|
|
export PATH="$ROOT/bin:$PATH"
|
|
|
|
GEN="$ROOT/proto/example_zap.lua"
|
|
SKIP_GEN=""
|
|
|
|
if [ ! -f "$GEN" ]; then
|
|
"$ROOT/tools/gen-example.sh" || true
|
|
fi
|
|
|
|
if [ ! -f "$GEN" ]; then
|
|
SKIP_GEN=1
|
|
echo "NOTE: proto/example_zap.lua not generated (no 'capnp' front-end on PATH);"
|
|
echo " skipping tests/01-sanity.lua and tests/10-encode-decode.lua."
|
|
fi
|
|
|
|
rc=0
|
|
for file in "$ROOT"/tests/*.lua
|
|
do
|
|
base=$(basename "$file")
|
|
if [ -n "$SKIP_GEN" ] && { [ "$base" = "01-sanity.lua" ] || [ "$base" = "10-encode-decode.lua" ]; }; then
|
|
echo
|
|
echo "Skipping $base (needs proto/example_zap.lua)"
|
|
continue
|
|
fi
|
|
echo
|
|
echo "Running $base..."
|
|
luajit "$file" || rc=1
|
|
done
|
|
|
|
exit $rc
|