Files
breeze/tests/bottom_nav_policy_zi_test.sh
waozi 458f4fb5eb Run the test harnesses on the Ziran 0.6 toolchain
Point every harness's default toolchain at build/packages/ziran/build,
drop the removed `zi2zx bundle` form, link the generated C each harness
actually gets (whole generated folders where the test has no stubs, and
Kryon's package-prefixed frame pacing module), and stop listing the
header-only type module in the modal rules test. Twenty-two more test
targets pass from a clean export; plans/2026-11-17-test-harnesses.md
lists the 54 that still fail and why.
2026-11-17 03:12:21 -03:00

57 lines
1.8 KiB
Bash

#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
bin=${1:-"$root/build/packages/ziran/build/bin"}
work=$root/build/bottom-nav-policy-test
source=$root/tests/bottom_nav_policy_behavior.zi
include=${ZIRAN_INCLUDE:-"$root/build/packages/ziran/include"}
mkdir -p "$work/ir"
"$bin/zi2zir" --root "$root/tests" --module-path "$root/src" \
-o "$work/ir" "$source"
for input in source saved; do
if [ "$input" = source ]; then
file=$source
module_root=$root/tests
app_path=$root/src
else
file=$work/ir/bottom_nav_policy_behavior.zir
module_root=$work/ir
app_path=$work/ir
fi
output=$work/$input
mkdir -p "$output/c" "$output/go"
"$bin/zi2zx" --root "$module_root" \
--module-path "$app_path" \
--entry bottom_nav_policy_behavior:Answer \
-o "$output/policy.zx" "$file"
[ "$(env -u DISPLAY -u WAYLAND_DISPLAY "$bin/zi2zx" run "$output/policy.zx")" = 42 ]
"$bin/zi2c" --no-main --root "$module_root" \
--module-path "$app_path" -o "$output/c" "$file"
cat > "$output/c/main.c" <<'C'
#include "bottom_nav_policy_behavior.h"
int main(void) { return Answer() == 42 ? 0 : 1; }
C
"${CC:-cc}" -std=c11 -DZIRAN_BOUNDS_CHECK \
-I"$include" -I"$output/c" "$output/c"/*.c -o "$output/c/test"
env -u DISPLAY -u WAYLAND_DISPLAY "$output/c/test"
"$bin/zi2go" --no-main --root "$module_root" \
--module-path "$app_path" -o "$output/go" "$file"
cat > "$output/go/bottom_nav_policy_behavior_test.go" <<'GO'
package ziran
import "testing"
func TestBottomNavPolicy(t *testing.T) {
if got := BottomNavPolicyBehavior_Answer(); got != 42 {
t.Fatalf("bottom navigation policy: got %d, want 42", got)
}
}
GO
GO111MODULE=off go test "$output/go"/*.go
done
cmp "$work/source/policy.zx" "$work/saved/policy.zx"