Files
hakorune/tools/selfhost_smoke.sh
nyash-codex 97a776aac3 feat(phase73): Stage-3 ENV consolidation complete - Shell scripts
Phase 73-B: Unified legacy Stage-3 environment variables in 27 shell scripts:
- Replaced NYASH_PARSER_STAGE3=1 → NYASH_FEATURES=stage3
- Replaced HAKO_PARSER_STAGE3=1 → NYASH_FEATURES=stage3
- Updated all variant patterns (with/without assignments)

Files modified (27 total):
- tools/dev/*.sh (9 files)
- tools/dev_stageb.sh, dump_stageb_min_mir.sh, hakorune_emit_mir.sh
- tools/joinir_ab_test.sh, ny_selfhost_inline.sh
- tools/perf/*.sh, tools/selfhost/*.sh (9 files)
- tools/hako_check/dot_edges_smoke.sh, tools/selfhost_smoke.sh

Complete Phase 73 consolidation count:
- Phase 73-A: 20 test files + 2 special files (stage3 compat)
- Phase 73-B: 27 shell script files
- Total: 49 files with legacy Stage-3 ENV consolidated

Next: Phase 72 (JoinIR EXPERIMENT SSOT consolidation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 12:38:01 +09:00

56 lines
2.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# Self-host minimal smoke (dev-only)
# - Emits MIR(JSON v0) via selfhost compiler MVP
# - Runs a representative VM example with Known rewrite ON/OFF and compares outputs
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
NY_BIN="${ROOT_DIR}/target/release/nyash"
if [[ ! -x "${NY_BIN}" ]]; then
echo "[selfhost-smoke] nyash binary not found at ${NY_BIN}. Please build first: cargo build --release" >&2
exit 1
fi
echo "[selfhost-smoke] Step 1: Emit JSON via selfhost compiler (lang/, optional)"
OUT_JSON="/tmp/nyash_selfhost_out.json"
set -x
# Use lang side entry (StageB). Emission is optional; failure does not fail the smoke.
if NYASH_ENABLE_USING=1 NYASH_ALLOW_USING_FILE=1 NYASH_USING_AST=1 NYASH_FEATURES=stage3 \
"${NY_BIN}" --backend vm "${ROOT_DIR}/lang/src/compiler/entry/compiler_stageb.hako" -- --source 'box Main { static method main() { return 0 } }' > "${OUT_JSON}" 2>/dev/null; then
:
else
echo "[selfhost-smoke] WARN: selfhost compiler emission failed (policy/duplicates?). Continuing." >&2
fi
set +x
if [[ -s "${OUT_JSON}" ]]; then
echo "[selfhost-smoke] Emitted JSON: ${OUT_JSON} ($(wc -c < "${OUT_JSON}") bytes)"
else
echo "[selfhost-smoke] NOTE: no JSON emitted (skipped). This is optional for the minimal smoke." >&2
fi
echo "[selfhost-smoke] Step 2: Run representative VM example (rewrite=ON/OFF)"
EXAMPLE="apps/examples/json_query/main.hako"
OUT_ON="/tmp/nyash_selfhost_vm_on.txt"
OUT_OFF="/tmp/nyash_selfhost_vm_off.txt"
set -x
"${NY_BIN}" --backend vm "${EXAMPLE}" > "${OUT_ON}"
NYASH_REWRITE_KNOWN_DEFAULT=0 "${NY_BIN}" --backend vm "${EXAMPLE}" > "${OUT_OFF}"
set +x
if ! diff -u "${OUT_ON}" "${OUT_OFF}" >/dev/null 2>&1; then
echo "[selfhost-smoke] WARN: output differs between rewrite ON and OFF" >&2
echo "--- ON (${OUT_ON})" >&2
head -n 20 "${OUT_ON}" >&2 || true
echo "--- OFF (${OUT_OFF})" >&2
head -n 20 "${OUT_OFF}" >&2 || true
# Non-fatal: keep smoke informative; do not fail hard unless required.
else
echo "[selfhost-smoke] VM outputs match for rewrite ON/OFF (good)."
fi
echo "[selfhost-smoke] PASS"