test(smokes): dedupe LLVM EXE scripts via llvm_exe_runner
This commit is contained in:
179
tools/smokes/v2/lib/llvm_exe_runner.sh
Normal file
179
tools/smokes/v2/lib/llvm_exe_runner.sh
Normal file
@ -0,0 +1,179 @@
|
||||
#!/bin/bash
|
||||
# llvm_exe_runner.sh - Shared helpers for LLVM EXE parity smokes (integration)
|
||||
#
|
||||
# SSOT goals:
|
||||
# - One place for "LLVM available?" SKIP logic
|
||||
# - One place for "required plugins are dlopen-able" gating + conditional build-all
|
||||
# - One place for "build_llvm.sh → run exe → numeric output compare"
|
||||
#
|
||||
# This file is meant to be sourced from smoke scripts that already source:
|
||||
# tools/smokes/v2/lib/test_runner.sh
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
llvm_exe_preflight_or_skip() {
|
||||
if ! command -v llvm-config-18 &>/dev/null; then
|
||||
test_skip "llvm-config-18 not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
llvm_exe_check_plugins() {
|
||||
# Args: repeated triples: <DisplayName> <SoPath> <CrateName>
|
||||
python3 - "$@" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
|
||||
args = sys.argv[1:]
|
||||
if len(args) % 3 != 0:
|
||||
print(f"[internal] expected triples, got {len(args)} args")
|
||||
sys.exit(2)
|
||||
|
||||
failures = []
|
||||
for i in range(0, len(args), 3):
|
||||
display, path, _crate = args[i], args[i + 1], args[i + 2]
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {display}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {display}: {path} ({e})")
|
||||
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
llvm_exe_ensure_plugins_or_fail() {
|
||||
# Uses global array LLVM_REQUIRED_PLUGINS (triples encoded as "Display|SoPath|CrateName")
|
||||
if ! declare -p LLVM_REQUIRED_PLUGINS >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
if [ "${#LLVM_REQUIRED_PLUGINS[@]}" -eq 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local -a triples=()
|
||||
local -a crate_names=()
|
||||
local CHECK_OUTPUT
|
||||
local item display so_path crate_name
|
||||
|
||||
for item in "${LLVM_REQUIRED_PLUGINS[@]}"; do
|
||||
IFS='|' read -r display so_path crate_name <<<"$item"
|
||||
if [ -z "${display:-}" ] || [ -z "${so_path:-}" ] || [ -z "${crate_name:-}" ]; then
|
||||
echo "[FAIL] Invalid LLVM_REQUIRED_PLUGINS entry: '$item'"
|
||||
return 1
|
||||
fi
|
||||
triples+=("$display" "$so_path" "$crate_name")
|
||||
crate_names+=("$crate_name")
|
||||
done
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (LLVM EXE)"
|
||||
if CHECK_OUTPUT=$(llvm_exe_check_plugins "${triples[@]}" 2>&1); then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all"
|
||||
|
||||
local build_log="${LLVM_PLUGIN_BUILD_LOG:-/tmp/llvm_exe_plugin_build.log}"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" "${crate_names[@]}" >"$build_log" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed"
|
||||
tail -n 80 "$build_log"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! CHECK_OUTPUT=$(llvm_exe_check_plugins "${triples[@]}" 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$build_log"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
llvm_exe_build_and_run_numeric_smoke() {
|
||||
# Required globals:
|
||||
# - INPUT_HAKO
|
||||
# - OUTPUT_EXE
|
||||
# - EXPECTED (multiline)
|
||||
# - EXPECTED_LINES (number of numeric lines to compare)
|
||||
#
|
||||
# Optional:
|
||||
# - LLVM_BUILD_LOG
|
||||
# - RUN_TIMEOUT_SECS
|
||||
|
||||
if [ -z "${INPUT_HAKO:-}" ] || [ -z "${OUTPUT_EXE:-}" ] || [ -z "${EXPECTED:-}" ]; then
|
||||
echo "[FAIL] llvm_exe_build_and_run_numeric_smoke: missing INPUT_HAKO/OUTPUT_EXE/EXPECTED"
|
||||
return 1
|
||||
fi
|
||||
if [ -z "${EXPECTED_LINES:-}" ]; then
|
||||
echo "[FAIL] llvm_exe_build_and_run_numeric_smoke: missing EXPECTED_LINES"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$OUTPUT_EXE")"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
local build_log="${LLVM_BUILD_LOG:-/tmp/llvm_exe_build.log}"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$build_log"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$build_log"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
local output
|
||||
output=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
local exit_code=$?
|
||||
set -e
|
||||
|
||||
if [ "$exit_code" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $exit_code"
|
||||
echo "$output" | tail -n 80
|
||||
return 1
|
||||
fi
|
||||
|
||||
local clean
|
||||
clean=$(printf "%s\n" "$output" | grep -v '^\[' | grep -E '^-?[0-9]+$' | head -n "$EXPECTED_LINES" | tr -d '\r')
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$clean"
|
||||
|
||||
if [ "$clean" = "$EXPECTED" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$output" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
return 1
|
||||
}
|
||||
@ -3,115 +3,29 @@
|
||||
# Tests: out = out + ch (string accumulator) and count = count + 1 (integer accumulator)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
|
||||
# Note: This fixture doesn't actually use FileBox/MapBox plugins,
|
||||
# but we follow the Phase 97 plugin gating pattern for consistency
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (FileBox/MapBox)"
|
||||
BUILD_LOG="/tmp/phase100_mutable_accumulator_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" nyash-filebox-plugin nyash-map-plugin >"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for FileBox/MapBox"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase100_mutable_accumulator_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase100_mutable_accumulator_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase100_mutable_accumulator_min"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase100_mutable_accumulator_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract numeric output only (same SSOT as VM smoke test)
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -E '^[0-9]+$' | head -n 1 | tr -d '\r')
|
||||
EXPECTED="3"
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED=$'3'
|
||||
EXPECTED_LINES=1
|
||||
LLVM_BUILD_LOG="/tmp/phase100_mutable_accumulator_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase100_mutable_accumulator_llvm_exe: output matches expected (3)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -2,119 +2,36 @@
|
||||
# Phase 100 P3 - String Accumulator (LLVM EXE backend)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
|
||||
# Phase 97/98 SSOT: plugin dlopen check → build only if needed → dlopen recheck.
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
|
||||
STRINGBOX_SO="$NYASH_ROOT/plugins/nyash-string-plugin/libnyash_string_plugin.so"
|
||||
CONSOLEBOX_SO="$NYASH_ROOT/plugins/nyash-console-plugin/libnyash_console_plugin.so"
|
||||
INTEGERBOX_SO="$NYASH_ROOT/plugins/nyash-integer-plugin/libnyash_integer_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" "$STRINGBOX_SO" "$CONSOLEBOX_SO" "$INTEGERBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox", "StringBox", "ConsoleBox", "IntegerBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox/StringBox/ConsoleBox/IntegerBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (core plugins)"
|
||||
BUILD_LOG="/tmp/phase100_string_accumulator_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" \
|
||||
nyash-filebox-plugin nyash-map-plugin nyash-string-plugin nyash-console-plugin nyash-integer-plugin \
|
||||
>"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for core plugins"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
|
||||
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
|
||||
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase100_string_accumulator_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase100_string_accumulator_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase100_string_accumulator_min"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase100_string_accumulator_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract numeric output only (consistent with other Phase100 LLVM EXE smokes)
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -E '^[0-9]+$' | head -n 1 | tr -d '\r')
|
||||
EXPECTED="3"
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED=$'3'
|
||||
EXPECTED_LINES=1
|
||||
LLVM_BUILD_LOG="/tmp/phase100_string_accumulator_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase100_string_accumulator_llvm_exe: output matches expected (3)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -2,119 +2,35 @@
|
||||
# Phase 102: real-app read_quoted loop (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
|
||||
# Phase 97/98/100 SSOT: plugin dlopen check → build only if needed → dlopen recheck.
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
|
||||
STRINGBOX_SO="$NYASH_ROOT/plugins/nyash-string-plugin/libnyash_string_plugin.so"
|
||||
CONSOLEBOX_SO="$NYASH_ROOT/plugins/nyash-console-plugin/libnyash_console_plugin.so"
|
||||
INTEGERBOX_SO="$NYASH_ROOT/plugins/nyash-integer-plugin/libnyash_integer_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" "$STRINGBOX_SO" "$CONSOLEBOX_SO" "$INTEGERBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox", "StringBox", "ConsoleBox", "IntegerBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox/StringBox/ConsoleBox/IntegerBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (core plugins)"
|
||||
BUILD_LOG="/tmp/phase102_realapp_read_quoted_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" \
|
||||
nyash-filebox-plugin nyash-map-plugin nyash-string-plugin nyash-console-plugin nyash-integer-plugin \
|
||||
>"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for core plugins"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
|
||||
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
|
||||
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase102_realapp_read_quoted_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase102_realapp_read_quoted_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase102_realapp_read_quoted_min"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase102_realapp_read_quoted_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -E '^-?[0-9]+$' | head -n 1 | tr -d '\r')
|
||||
EXPECTED="4"
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED=$'4'
|
||||
EXPECTED_LINES=1
|
||||
LLVM_BUILD_LOG="/tmp/phase102_realapp_read_quoted_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase102_realapp_read_quoted_llvm_exe: output matches expected (4)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -2,21 +2,11 @@
|
||||
# Phase 103 P1: if-only early return regression (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
# Phase 97/98/100 SSOT: plugin dlopen check → build only if needed → dlopen recheck.
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
@ -25,96 +15,24 @@ STRINGBOX_SO="$NYASH_ROOT/plugins/nyash-string-plugin/libnyash_string_plugin.so"
|
||||
CONSOLEBOX_SO="$NYASH_ROOT/plugins/nyash-console-plugin/libnyash_console_plugin.so"
|
||||
INTEGERBOX_SO="$NYASH_ROOT/plugins/nyash-integer-plugin/libnyash_integer_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" "$STRINGBOX_SO" "$CONSOLEBOX_SO" "$INTEGERBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox", "StringBox", "ConsoleBox", "IntegerBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox/StringBox/ConsoleBox/IntegerBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (core plugins)"
|
||||
BUILD_LOG="/tmp/phase103_if_only_early_return_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" \
|
||||
nyash-filebox-plugin nyash-map-plugin nyash-string-plugin nyash-console-plugin nyash-integer-plugin \
|
||||
>"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for core plugins"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
|
||||
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
|
||||
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase103_if_only_early_return_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase103_if_only_early_return_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase103_if_only_early_return_llvm_exe"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase103_if_only_early_return_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXPECTED=$'7\n2'
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -v '^\[' | grep -E '^-?[0-9]+$' | head -n 2 | paste -sd '\n' - | tr -d '\r')
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED_LINES=2
|
||||
LLVM_BUILD_LOG="/tmp/phase103_if_only_early_return_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase103_if_only_early_return_llvm_exe: output matches expected (7, 2)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -2,21 +2,11 @@
|
||||
# Phase 103: if-only merge regression (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
# Phase 97/98/100 SSOT: plugin dlopen check → build only if needed → dlopen recheck.
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
@ -25,96 +15,24 @@ STRINGBOX_SO="$NYASH_ROOT/plugins/nyash-string-plugin/libnyash_string_plugin.so"
|
||||
CONSOLEBOX_SO="$NYASH_ROOT/plugins/nyash-console-plugin/libnyash_console_plugin.so"
|
||||
INTEGERBOX_SO="$NYASH_ROOT/plugins/nyash-integer-plugin/libnyash_integer_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" "$STRINGBOX_SO" "$CONSOLEBOX_SO" "$INTEGERBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox", "StringBox", "ConsoleBox", "IntegerBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox/StringBox/ConsoleBox/IntegerBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (core plugins)"
|
||||
BUILD_LOG="/tmp/phase103_if_only_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" \
|
||||
nyash-filebox-plugin nyash-map-plugin nyash-string-plugin nyash-console-plugin nyash-integer-plugin \
|
||||
>"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for core plugins"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
|
||||
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
|
||||
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase103_if_only_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase103_if_only_merge_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase103_if_only_llvm_exe"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase103_if_only_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -v '^\[' | grep -E '^-?[0-9]+$' | head -n 1 | tr -d '\r')
|
||||
EXPECTED="2"
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED=$'2'
|
||||
EXPECTED_LINES=1
|
||||
LLVM_BUILD_LOG="/tmp/phase103_if_only_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase103_if_only_llvm_exe: output matches expected (2)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -2,21 +2,11 @@
|
||||
# Phase 104: read_digits loop(true) + break-only (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
# Phase 97/98/100 SSOT: plugin dlopen check → build only if needed → dlopen recheck.
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
@ -25,96 +15,24 @@ STRINGBOX_SO="$NYASH_ROOT/plugins/nyash-string-plugin/libnyash_string_plugin.so"
|
||||
CONSOLEBOX_SO="$NYASH_ROOT/plugins/nyash-console-plugin/libnyash_console_plugin.so"
|
||||
INTEGERBOX_SO="$NYASH_ROOT/plugins/nyash-integer-plugin/libnyash_integer_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" "$STRINGBOX_SO" "$CONSOLEBOX_SO" "$INTEGERBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox", "StringBox", "ConsoleBox", "IntegerBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox/StringBox/ConsoleBox/IntegerBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (core plugins)"
|
||||
BUILD_LOG="/tmp/phase104_read_digits_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" \
|
||||
nyash-filebox-plugin nyash-map-plugin nyash-string-plugin nyash-console-plugin nyash-integer-plugin \
|
||||
>"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for core plugins"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
|
||||
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
|
||||
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase104_read_digits_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase104_read_digits_loop_true_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase104_read_digits_llvm_exe"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase104_read_digits_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXPECTED=$'2\n1'
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -v '^\[' | grep -E '^-?[0-9]+$' | head -n 2 | paste -sd '\n' - | tr -d '\r')
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED_LINES=2
|
||||
LLVM_BUILD_LOG="/tmp/phase104_read_digits_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase104_read_digits_llvm_exe: output matches expected (2, 1)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@ -2,65 +2,21 @@
|
||||
# Phase 97: json_loader escape loop (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (FileBox/MapBox)"
|
||||
BUILD_LOG="/tmp/phase97_json_loader_escape_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" nyash-filebox-plugin nyash-map-plugin >"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for FileBox/MapBox"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase97_json_loader_escape_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
|
||||
|
||||
@ -2,112 +2,30 @@
|
||||
# Phase 97: next_non_ws fixture (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (FileBox/MapBox)"
|
||||
BUILD_LOG="/tmp/phase97_next_non_ws_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" nyash-filebox-plugin nyash-map-plugin >"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for FileBox/MapBox"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase97_next_non_ws_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase96_json_loader_next_non_ws_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase97_next_non_ws_llvm_exe"
|
||||
|
||||
echo "[INFO] Building: $INPUT_HAKO → $OUTPUT_EXE"
|
||||
|
||||
BUILD_LOG="/tmp/phase97_next_non_ws_build.log"
|
||||
if ! env NYASH_DISABLE_PLUGINS=0 "$NYASH_ROOT/tools/build_llvm.sh" "$INPUT_HAKO" -o "$OUTPUT_EXE" 2>&1 | tee "$BUILD_LOG"; then
|
||||
echo "[FAIL] build_llvm.sh failed"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "$OUTPUT_EXE" ]; then
|
||||
echo "[FAIL] Executable not created or not executable: $OUTPUT_EXE"
|
||||
ls -la "$OUTPUT_EXE" 2>/dev/null || echo "File does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[INFO] Executing: $OUTPUT_EXE"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "${RUN_TIMEOUT_SECS:-10}" env NYASH_DISABLE_PLUGINS=0 "$OUTPUT_EXE" 2>&1)
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
echo "[FAIL] Execution failed with exit code $EXIT_CODE"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -v '^\[' | grep -E '^-?[0-9]+$' | head -n 3 | tr -d '\r')
|
||||
EXPECTED=$'2\n-1\n3'
|
||||
|
||||
echo "[INFO] CLEAN output:"
|
||||
echo "$CLEAN"
|
||||
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
EXPECTED_LINES=3
|
||||
LLVM_BUILD_LOG="/tmp/phase97_next_non_ws_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase97_next_non_ws_llvm_exe: output matches expected (2, -1, 3)"
|
||||
else
|
||||
echo "[FAIL] Output mismatch"
|
||||
echo "[INFO] Raw output (tail):"
|
||||
echo "$OUTPUT" | tail -n 80
|
||||
echo "[INFO] Expected:"
|
||||
printf "%s\n" "$EXPECTED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -2,65 +2,21 @@
|
||||
# Phase 99: escape trailing backslash fixture (LLVM EXE parity)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
|
||||
export SMOKES_USE_PYVM=0
|
||||
require_env || exit 2
|
||||
|
||||
# LLVM availability checks (graceful SKIP)
|
||||
if ! command -v llvm-config-18 &> /dev/null; then
|
||||
test_skip "llvm-config-18 not found"; exit 0
|
||||
fi
|
||||
|
||||
if ! "$NYASH_BIN" --help 2>&1 | grep -q "llvm"; then
|
||||
test_skip "hakorune --backend llvm not available"; exit 0
|
||||
fi
|
||||
|
||||
if ! python3 -c "import llvmlite" 2>/dev/null; then
|
||||
test_skip "Python llvmlite not found"; exit 0
|
||||
fi
|
||||
llvm_exe_preflight_or_skip || exit 0
|
||||
|
||||
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
|
||||
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
|
||||
|
||||
check_plugins() {
|
||||
python3 - "$FILEBOX_SO" "$MAPBOX_SO" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
names = ["FileBox", "MapBox"]
|
||||
paths = sys.argv[1:]
|
||||
failures = []
|
||||
for name, path in zip(names, paths):
|
||||
if not os.path.isfile(path):
|
||||
failures.append(f"[plugin/missing] {name}: {path}")
|
||||
continue
|
||||
try:
|
||||
ctypes.CDLL(path)
|
||||
except Exception as e: # noqa: BLE001
|
||||
failures.append(f"[plugin/dlopen] {name}: {path} ({e})")
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
sys.exit(1)
|
||||
print("OK")
|
||||
PY
|
||||
}
|
||||
|
||||
echo "[INFO] Checking plugin artifacts (FileBox/MapBox)"
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[INFO] Missing/broken plugin detected, running build-all (FileBox/MapBox)"
|
||||
BUILD_LOG="/tmp/phase99_escape_trailing_backslash_plugin_build.log"
|
||||
if ! bash "$NYASH_ROOT/tools/plugins/build-all.sh" nyash-filebox-plugin nyash-map-plugin >"$BUILD_LOG" 2>&1; then
|
||||
echo "[FAIL] tools/plugins/build-all.sh failed for FileBox/MapBox"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
if ! CHECK_OUTPUT=$(check_plugins 2>&1); then
|
||||
echo "$CHECK_OUTPUT"
|
||||
echo "[FAIL] Plugin artifacts still missing or unloadable after build-all"
|
||||
tail -n 80 "$BUILD_LOG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
LLVM_REQUIRED_PLUGINS=(
|
||||
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
|
||||
"MapBox|$MAPBOX_SO|nyash-map-plugin"
|
||||
)
|
||||
LLVM_PLUGIN_BUILD_LOG="/tmp/phase99_escape_trailing_backslash_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
mkdir -p "$NYASH_ROOT/tmp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user