zi2zx bundle and ziran run always write and run revision-28 executable ZX. The semantic bundle reader and writer, the portable VM, the TinyCC-compiled and linked native bundles with the vendored TinyCC, bundle libraries, the VM profile, --vm, BundleInstantiatePortable, libziran-vm.a and the ZIR-based Wasm lowering with zi2wasm are removed; the Wasm tier, the embedding API and every tool run revision 28. Tests of the removed VM internals and libraries are removed, and the rest run on revision 28. Engine problems read as the diagnostics users rely on.
53 lines
2.1 KiB
Bash
53 lines
2.1 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
ziran=${1:?pass the ziran command}
|
|
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
work=$(mktemp -d "$repo/build/tests/function-plans-XXXXXX")
|
|
trap 'rm -rf "$work"' EXIT HUP INT TERM
|
|
unset DISPLAY WAYLAND_DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
|
|
source=$work/vm_function_plans_test.zi
|
|
cp "$repo/tests/spec/vm_function_plans_test.zi" "$source"
|
|
# Force control-flow targets beyond a byte without an enormous source fixture.
|
|
{
|
|
echo 'Large :: (seed: s64, limit: s32, choose: bool) -> s64 {'
|
|
echo 'total := seed; i: s32; while i < limit {'
|
|
count=0
|
|
while test "$count" -lt 40; do
|
|
echo 'if choose { total += seed + 3 } else { total ^= seed - 7 }'
|
|
count=$((count + 1))
|
|
done
|
|
echo 'i += 1'
|
|
echo '}'
|
|
echo 'return total'
|
|
echo '}'
|
|
} >> "$source"
|
|
"$ziran" ir --root "$work" --module-path "$repo/std" -o "$work/ir" "$source"
|
|
for form in source saved; do
|
|
input=$source
|
|
root=$work
|
|
if test "$form" = saved; then input=$work/ir/vm_function_plans_test.zir; root=$work/ir; fi
|
|
"$ziran" bundle --root "$root" --module-path "$repo/std" --entry vm_function_plans_test:Answer \
|
|
-o "$work/$form.zx" "$input"
|
|
test "$("$ziran" run "$work/$form.zx")" = 42
|
|
for target in c go; do
|
|
output=$work/$target-$form
|
|
"$ziran" build --target="$target" --root "$root" --module-path "$repo/std" -o "$output" "$input"
|
|
if test "$target" = go; then
|
|
cat > "$output/plans_test.go" <<'GO'
|
|
package ziran
|
|
import "testing"
|
|
func TestProcedureCalls(t *testing.T) {
|
|
if result := VmFunctionPlansTest_Answer(); result != 42 { t.Fatal(result) }
|
|
}
|
|
GO
|
|
GO111MODULE=off go test "$output"/*.go
|
|
else
|
|
compiler=${CC:-cc}; ext=c; header=h; standard=c11
|
|
printf '#include "vm_function_plans_test.%s"\nint main(void) { return Answer() == 42 ? 0 : 1; }\n' "$header" > "$output/host.$ext"
|
|
"$compiler" -std="$standard" -I"$output" -I"$repo/include" "$output"/*."$ext" -o "$output/app"
|
|
"$output/app"
|
|
fi
|
|
done
|
|
done
|
|
cmp "$work/source.zx" "$work/saved.zx"
|