2025-09-15 18:44:49 +09:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# EXE-first smoke: build the selfhost parser EXE and run a tiny program end-to-end.
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
if [[ "${NYASH_CLI_VERBOSE:-0}" == "1" ]]; then set -x; fi
|
|
|
|
|
|
|
|
|
|
ROOT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
|
|
|
|
cd "$ROOT_DIR"
|
|
|
|
|
|
|
|
|
|
echo "[1/4] Building parser EXE bundle ..."
|
|
|
|
|
tools/build_compiler_exe.sh >/dev/null
|
|
|
|
|
|
|
|
|
|
echo "[2/4] Preparing sample source ..."
|
|
|
|
|
mkdir -p dist/nyash_compiler/tmp
|
2025-11-06 15:41:52 +09:00
|
|
|
echo 'return 1+2*3' > dist/nyash_compiler/tmp/sample_exe_smoke.hako
|
2025-09-15 18:44:49 +09:00
|
|
|
|
|
|
|
|
echo "[3/4] Running parser EXE → JSON ..."
|
2025-11-06 15:41:52 +09:00
|
|
|
(cd dist/nyash_compiler && timeout -s KILL 60s ./nyash_compiler tmp/sample_exe_smoke.hako > sample.json)
|
2025-09-17 20:33:19 +09:00
|
|
|
|
|
|
|
|
echo "[3.5/4] Validating JSON schema ..."
|
|
|
|
|
python3 tools/validate_mir_json.py dist/nyash_compiler/sample.json
|
2025-09-15 18:44:49 +09:00
|
|
|
|
|
|
|
|
if ! head -n1 dist/nyash_compiler/sample.json | grep -q '"kind":"Program"'; then
|
|
|
|
|
echo "error: JSON does not look like a Program" >&2
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "[4/4] Executing via bridge (pipe) to verify semantics ..."
|
|
|
|
|
# Keep core minimal and deterministic
|
|
|
|
|
export NYASH_DISABLE_PLUGINS=1
|
2025-12-10 00:01:53 +09:00
|
|
|
BIN=${NYASH_BIN:-./target/release/hakorune}
|
2025-09-15 18:44:49 +09:00
|
|
|
set +e
|
2025-12-10 00:01:53 +09:00
|
|
|
timeout -s KILL 60s bash -c "cat dist/nyash_compiler/sample.json | ${BIN} --ny-parser-pipe --backend vm >/dev/null"
|
2025-09-15 18:44:49 +09:00
|
|
|
RC=$?
|
|
|
|
|
set -e
|
|
|
|
|
if [[ "$RC" -ne 7 ]]; then
|
|
|
|
|
echo "error: expected exit code 7, got $RC" >&2
|
|
|
|
|
exit 3
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "✅ EXE-first smoke passed (parser EXE + bridge run)"
|
|
|
|
|
exit 0
|