Files
ziran/tests/explain.sh
T
waozi 4838ce9b2f Improve runtimes, add an experimental direct backend, and prune Ziran tests
Prepare short portable helpers and scalar record reads, improve JSON SIMD scanning, expose one-line execution, and publish qualified Alpha benchmark artifacts. Add the experimental verified lowered execution, serialization and Linux x86-64 backend with source maps.

Physically remove 263 redundant test entry points and unused helpers, migrate retained helpers to Ziran, and execute the full retained suite without sharding. Allow ignored backup state for the managed physical Alpha workflow.

Local validation: all 268 retained tests passed across the full run and corrected targeted reruns; bootstrap matches. Current assembly verifier, x86-64, executor and serializer tests passed. Website examples and all 4661 local links passed. Six Alpha JSON/text workloads retain verified artifacts, raw samples and explicit unsupported Wasm diagnostics. The mobile sub-500 ns target remains pending.
2026-11-11 18:46:34 -03:00

61 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
set -eu
ziran=${1:?pass the ziran command}
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
mkdir -p "$repo/build/tests"
work=$(mktemp -d "$repo/build/tests/explain-XXXXXX")
trap 'rm -rf "$work"' EXIT HUP INT TERM
"$ziran" --help > "$work/help.txt"
grep -Fq 'explain' "$work/help.txt"
"$ziran" guide > "$work/guide.txt"
grep -Fq 'ziran explain --list --json' "$work/guide.txt"
"$ziran" explain check.slice_lifetime > "$work/text.txt"
grep -Fq 'code: check.slice_lifetime' "$work/text.txt"
grep -Fq 'borrowed slice or text view' "$work/text.txt"
grep -Fq 'Keep the owner live and immutable' "$work/text.txt"
"$ziran" explain zir.noncanonical --json > "$work/item.json"
"$ziran" explain --list --json > "$work/list.json"
"$ziran" run --target=c --root "$repo/tests" "$repo/tests/explain_cases.zi" -- "$ziran" "$work"
cat > "$work/go-import.zi" <<'ZI'
libc :: #system_library "libc";
Read :: (value: []u8) -> s32 #foreign libc "read";
ZI
if "$ziran" build --target=go --diagnostics=json --root "$work" \
-o "$work/go-import" "$work/go-import.zi" \
> "$work/go-import.out" 2> "$work/go-import.jsonl"; then
echo 'Go accepted an unsupported C ABI slice parameter' >&2
exit 1
fi
"$ziran" run --target=c --root "$repo/tests" "$repo/tests/json_assertions.zi" -- code-message "$work/go-import.jsonl" zir_go.import 'C ABI symbol'
cat > "$work/output.zi" <<'ZI'
#program_export
Answer :: () -> s32 { return 42 }
ZI
if "$ziran" build --target=go --diagnostics=json --root "$work" \
-o /proc/ziran-go-output "$work/output.zi" \
> "$work/output.out" 2> "$work/output.jsonl"; then
echo 'Go output failure did not fail the build' >&2
exit 1
fi
"$ziran" run --target=c --root "$repo/tests" "$repo/tests/json_assertions.zi" -- code-message "$work/output.jsonl" zir_go.global /proc/ziran-go-output
if "$ziran" build --target=c --diagnostics=json --root "$work" \
-o /proc/ziran-c-output "$work/output.zi" \
> "$work/c-output.out" 2> "$work/c-output.jsonl"; then
echo "c output failure did not fail the build" >&2
exit 1
fi
"$ziran" run --target=c --root "$repo/tests" "$repo/tests/json_assertions.zi" -- code-message "$work/c-output.jsonl" zir_c.global /proc/ziran-
if "$ziran" explain check.not_a_code > "$work/bad.out" 2> "$work/bad.err"; then
echo 'explain accepted an unknown diagnostic code' >&2
exit 1
fi
grep -Fq 'unknown diagnostic code: check.not_a_code' "$work/bad.err"
if "$ziran" explain --json > "$work/no-code.out" 2> "$work/no-code.err"; then
echo 'explain accepted --json without a code or --list' >&2
exit 1
fi