OUTPUT_DIR="test_outputs" mkdir -p "$OUTPUT_DIR" echo "=== 编译器功能测试 ===" echo "结果将保存到 $OUTPUT_DIR/ 目录" echo "" for test in test/test_case/functional/*.sy; do name=$(basename "$test" .sy) echo "正在测试: $name" # 检查是否有对应的输入文件 in_file="test/test_case/functional/${name}.in" out_file="$OUTPUT_DIR/${name}.ll" if [ -f "$in_file" ]; then echo " 使用输入文件: $in_file" echo " 输出保存到: $out_file" echo "" ./build/bin/compiler --emit-ir "$test" < "$in_file" 2>&1 | tee "$out_file" else echo " 输出保存到: $out_file" echo "" ./build/bin/compiler --emit-ir "$test" 2>&1 | tee "$out_file" fi echo "" echo "--- 测试完成 ---" echo "" done echo "所有测试完成!" echo "查看结果: ls -la $OUTPUT_DIR/"