writeonce/runtime/test/cli_smoke.sh
shoney.arickathil bab88a53b9 feat(runtime): wovm VM core (Iteration 2)
- 16 tasks complete: arena, object model, borrow word, containers,
  RC + budgeted cycle collector, wob_build, validating loader,
  interpreter core (dual dispatch), object opcodes, drop-map unwinding,
  builtins + DB_STUB + TRAP, ICALL, wovm CLI + just recipes
- 13 test suites × 2 dispatch flavors (ASan+UBSan) + CLI smoke, all green
- .wob v1 format pinned in src/wob.h + docs/plan/oop-vm/00-wob-format.md
- wo-rt.c reference event-loop preserved for sub-project 2

This is Iteration 2 of the OOP milestone; compiler front (Iteration 3)
is in progress on this branch. They meet at Iteration 4 (emitter+e2e).
2026-08-10 09:35:55 +02:00

31 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# cli_smoke — end-to-end check of the wovm CLI exit-code contract:
# 0 = success, 1 = trap (one stderr line: "trap CODE in METHOD at line N:
# MESSAGE"), 2 = usage/load failure. Fixtures come from mkwob.
set -u
cd "$(dirname "$0")/.." || exit 1
make wovm build/mkwob >/dev/null || { echo "cli_smoke: build failed"; exit 1; }
./build/mkwob build || { echo "cli_smoke: mkwob failed"; exit 1; }
# success path: stdout diffed, exit 0
out=$(./wovm build/hello.wob)
rc=$?
[ "$rc" -eq 0 ] || { echo "cli_smoke: hello exit $rc, want 0"; exit 1; }
expected=$'hello, wovm\n42'
[ "$out" = "$expected" ] || { echo "cli_smoke: unexpected stdout: $out"; exit 1; }
# trap path: exit 1, fixed stderr shape
./wovm build/trap.wob >/dev/null 2>build/trap.err
rc=$?
[ "$rc" -eq 1 ] || { echo "cli_smoke: trap exit $rc, want 1"; exit 1; }
grep -q '^trap 1 in main at line 7: division by zero$' build/trap.err ||
{ echo "cli_smoke: bad trap line: $(cat build/trap.err)"; exit 1; }
# load-failure path: exit 2
./wovm build/does-not-exist.wob 2>/dev/null
[ $? -eq 2 ] || { echo "cli_smoke: missing-file exit not 2"; exit 1; }
./wovm 2>/dev/null
[ $? -eq 2 ] || { echo "cli_smoke: usage exit not 2"; exit 1; }
echo "cli_smoke: OK"