Files
kryon/tests/ziran_composition_queue_test.sh
T

43 lines
1.2 KiB
Bash

#!/bin/sh
. "$(dirname -- "$0")/test_context.sh"
source=$repo/tests/ziran_composition_queue_test.zi
"$ziran" ir --root "$repo/tests" --module-path "$repo/src/backend" \
-o "$work/ir" "$source"
for input in source saved; do
if test "$input" = source; then
module=$source
root=$repo/tests
path=$repo/src/backend
else
module=$work/ir/ziran_composition_queue_test.zir
root=$work/ir
path=$work/ir
fi
for target in c go; do
output=$work/$input-$target
if test "$target" = go; then
"$ziran" build --target=go --pkg main --root "$root" \
--module-path "$path" -o "$output" "$module"
else
"$ziran" build --target="$target" --root "$root" \
--module-path "$path" -o "$output" "$module"
fi
if test "$target" = c; then
"${CC:-cc}" -std=c11 -I"$ziran_root/include" -I"$output" \
"$output"/*.c -o "$output/app"
"$output/app"
else
cat > "$output/main.go" <<'GO'
package main
func main() {
if ZiranCompositionQueueTest_Main() != 0 { panic("composition queue failed") }
}
GO
GO111MODULE=off go run "$output"/*.go
fi
done
done