forked from NUDT-compiler/nudt-compiler-cpp
Compare commits
4 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
6fc0c89072 | 2 weeks ago |
|
|
995e159f6f | 2 weeks ago |
|
|
7115f7e49d | 2 weeks ago |
|
|
d6e4fa016e | 2 weeks ago |
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 批量测试所有.sy文件的语法解析
|
||||
|
||||
test_dir="/home/lingli/nudt-compiler-cpp/test/test_case"
|
||||
compiler="/home/lingli/nudt-compiler-cpp/build/bin/compiler"
|
||||
|
||||
if [ ! -f "$compiler" ]; then
|
||||
echo "错误:编译器不存在,请先构建项目"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
success_count=0
|
||||
failed_count=0
|
||||
failed_tests=()
|
||||
|
||||
echo "开始测试所有.sy文件的语法解析..."
|
||||
echo "="
|
||||
|
||||
# 获取所有.sy文件并排序
|
||||
for test_file in $(find "$test_dir" -name "*.sy" | sort); do
|
||||
echo "测试: $(basename "$test_file")"
|
||||
|
||||
# 运行解析测试,捕获输出
|
||||
output=$("$compiler" --emit-parse-tree "$test_file" 2>&1)
|
||||
exit_code=$?
|
||||
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo " ✓ 成功"
|
||||
((success_count++))
|
||||
else
|
||||
echo " ✗ 失败"
|
||||
echo " 错误信息: $output"
|
||||
((failed_count++))
|
||||
failed_tests+=($(basename "$test_file"))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "="
|
||||
echo "测试完成!"
|
||||
echo "总测试数: $((success_count + failed_count))"
|
||||
echo "成功: $success_count"
|
||||
echo "失败: $failed_count"
|
||||
|
||||
if [ $failed_count -gt 0 ]; then
|
||||
echo "失败的测试用例:"
|
||||
for test in "${failed_tests[@]}"; do
|
||||
echo " - $test"
|
||||
done
|
||||
fi
|
||||
Loading…
Reference in new issue