gomog/check_tests.sh

64 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 测试编译检查脚本
echo "======================================"
echo "GoMog Batch 2 测试编译检查"
echo "======================================"
echo ""
cd /home/kingecg/code/gomog
# 检查 go.mod 是否存在
if [ ! -f "go.mod" ]; then
echo "错误go.mod 文件不存在"
exit 1
fi
echo "✓ 找到 go.mod 文件"
# 尝试 tidy 模块
echo ""
echo "正在运行 go mod tidy..."
go mod tidy 2>&1
if [ $? -ne 0 ]; then
echo "✗ go mod tidy 失败"
exit 1
fi
echo "✓ go mod tidy 成功"
# 尝试编译所有测试文件
echo ""
echo "正在编译测试文件..."
# 编译 engine 包的测试
echo " - 编译 internal/engine 测试..."
go test -c ./internal/engine -o /tmp/engine_test.out 2>&1
if [ $? -ne 0 ]; then
echo "✗ internal/engine 测试编译失败"
exit 1
fi
echo " ✓ internal/engine 测试编译成功"
# 编译 http 包的测试
echo " - 编译 internal/protocol/http 测试..."
go test -c ./internal/protocol/http -o /tmp/http_test.out 2>&1
if [ $? -ne 0 ]; then
echo "✗ internal/protocol/http 测试编译失败"
exit 1
fi
echo " ✓ internal/protocol/http 测试编译成功"
# 清理
rm -f /tmp/engine_test.out /tmp/http_test.out
echo ""
echo "======================================"
echo "✓ 所有测试文件编译成功!"
echo "======================================"
echo ""
echo "提示:要运行测试,请使用:"
echo " go test -v ./internal/engine/..."
echo " go test -v ./internal/protocol/http/..."
echo ""