Files
hakorune/tools/joinir_ab_test.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

73 lines
1.7 KiB
Bash

#!/bin/bash
# Phase 33-8: A/B test automation for JoinIR lowering
#
# Usage:
# tools/joinir_ab_test.sh <test_file.hako>
#
# Example:
# tools/joinir_ab_test.sh apps/tests/joinir_if_merge_simple.hako
set -euo pipefail
test_case=$1 # e.g., "apps/tests/joinir_if_merge_simple.hako"
if [ ! -f "$test_case" ]; then
echo "❌ Test file not found: $test_case"
exit 1
fi
echo "🧪 Testing: $test_case"
echo ""
# Route A: Traditional if_phi
echo "=== Route A (if_phi) ==="
HAKO_JOINIR_IF_SELECT=0 \
NYASH_FEATURES=stage3 \
NYASH_FEATURES=stage3 \
./target/release/hakorune "$test_case" \
> /tmp/route_a.out 2>&1
route_a_rc=$?
echo "Route A RC: $route_a_rc"
echo ""
# Route B: JoinIR Select/IfMerge
echo "=== Route B (JoinIR) ==="
HAKO_JOINIR_IF_SELECT=1 \
HAKO_JOINIR_STAGE1=1 \
HAKO_JOINIR_DEBUG=1 \
NYASH_FEATURES=stage3 \
NYASH_FEATURES=stage3 \
./target/release/hakorune "$test_case" \
> /tmp/route_b.out 2>&1
route_b_rc=$?
echo "Route B RC: $route_b_rc"
echo ""
# Comparison
echo "=== 📊 Comparison ==="
# RC check
if [ $route_a_rc -eq $route_b_rc ]; then
echo "✅ RC matched: $route_a_rc"
else
echo "❌ RC mismatch: A=$route_a_rc, B=$route_b_rc"
exit 1
fi
# Output check (ignore debug logs starting with '[')
if diff <(grep -v '^\[' /tmp/route_a.out) <(grep -v '^\[' /tmp/route_b.out); then
echo "✅ Output matched"
else
echo "❌ Output differs:"
diff <(grep -v '^\[' /tmp/route_a.out) <(grep -v '^\[' /tmp/route_b.out) || true
exit 1
fi
# Extract lowering info from Route B
echo ""
echo "=== 🔍 Lowering Info ==="
grep -E "IfMerge|IfSelect|if_phi" /tmp/route_b.out || echo "⚠️ No lowering info found"
echo ""
echo "🎉 A/B test PASSED for $test_case"