Files
breeze/tests/modal_rules_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

65 lines
2.1 KiB
Bash

#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
bin=${1:-"$root/build/packages/ziran/build/bin"}
work=${MODAL_RULES_TEST_BUILD_DIR:-"$root/build/modal-rules-test"}
source=$root/tests/modal_rules_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
module_path=$root/src
else
file=$work/ir/modal_rules_behavior.zir
module_root=$work/ir
module_path=$work/ir
fi
output=$work/$input
rm -rf "$output/c" "$output/go"
mkdir -p "$output/c" "$output/go"
"$bin/zi2zx" --root "$module_root" \
--module-path "$module_path" \
--entry modal_rules_behavior:Answer \
-o "$output/modal_rules.zx" "$file"
actual=$("$bin/zi2zx" run "$output/modal_rules.zx")
if [ "$actual" != 42 ]; then
echo "modal rules $input bundle returned $actual; expected 42" >&2
exit 1
fi
"$bin/zi2c" --no-main --root "$module_root" \
--module-path "$module_path" -o "$output/c" "$file"
cat > "$output/c/main.c" <<'C'
#include "modal_rules_behavior.h"
int main(void) { return Answer() == 42 ? 0 : 1; }
C
"${CC:-cc}" -std=c11 -I"$include" -I"$output/c" \
"$output/c/modal_rules.c" \
"$output/c/modal_rules_behavior.c" "$output/c/main.c" \
-o "$output/c/test"
env -u DISPLAY -u WAYLAND_DISPLAY "$output/c/test"
"$bin/zi2go" --no-main --root "$module_root" \
--module-path "$module_path" -o "$output/go" "$file"
cat > "$output/go/modal_rules_behavior_test.go" <<'GO'
package ziran
import "testing"
func TestModalRules(t *testing.T) {
if got := ModalRulesBehavior_Answer(); got != 42 {
t.Fatalf("modal rules: got %d, want 42", got)
}
}
GO
GO111MODULE=off go test "$output/go"/*.go
done
cmp "$work/source/modal_rules.zx" "$work/saved/modal_rules.zx"
echo "modal rules Ziran test passed"