You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
666 B

#!/usr/bin/env bash
set -euo pipefail
case_dir="${1:-test/test_case}"
if [[ ! -d "$case_dir" ]]; then
echo "测试目录不存在: $case_dir" >&2
exit 1
fi
compiler="./build/bin/compiler"
if [[ ! -x "$compiler" ]]; then
echo "未找到编译器: $compiler ,请先构建 parse-only 版本。" >&2
exit 1
fi
mapfile -t cases < <(find "$case_dir" -name '*.sy' | sort)
if [[ ${#cases[@]} -eq 0 ]]; then
echo "未找到任何 .sy 测试文件: $case_dir" >&2
exit 1
fi
for f in "${cases[@]}"; do
echo "TEST $f"
"$compiler" --emit-parse-tree "$f" >/dev/null || {
echo "FAIL $f" >&2
exit 1
}
done
echo "ALL_PARSE_OK (${#cases[@]} cases)"