chore: sync project snapshot for gitea/github upload
This commit is contained in:
@@ -73,15 +73,14 @@ for TEST_CLASS in "${CRITICAL_TESTS[@]}"; do
|
||||
fi
|
||||
fi
|
||||
elif [[ "${REPORT_FILE}" == *.txt ]]; then
|
||||
# 从文本报告中提取信息
|
||||
if grep -q "Skipped" "${REPORT_FILE}"; then
|
||||
# 检查是否有跳过的测试
|
||||
if grep "Skipped.*[1-9]" "${REPORT_FILE}"; then
|
||||
echo " ERROR: ${TEST_CLASS} 有跳过的用例!"
|
||||
FAILED=1
|
||||
fi
|
||||
# 对于文本报告,提取 Skipped: 后面的数字并检查是否大于0
|
||||
SKIPPED_COUNT=$(grep -oP 'Skipped:\s*\K[0-9]+' "${REPORT_FILE}" 2>/dev/null || echo "0")
|
||||
if [[ "${SKIPPED_COUNT}" -gt 0 ]]; then
|
||||
echo " ERROR: ${TEST_CLASS} 有 ${SKIPPED_COUNT} 个被跳过的用例!"
|
||||
FAILED=1
|
||||
else
|
||||
echo " PASS: ${TEST_CLASS} 跳过数量为0(${SKIPPED_COUNT})"
|
||||
fi
|
||||
echo " INFO: 文本报告格式,跳过详细检查"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -121,10 +121,9 @@ run_test() {
|
||||
|
||||
mkdir -p "$(dirname "${evidence_path}")"
|
||||
|
||||
echo -e "\n${YELLOW}运行测试: ${test_name}${NC}"
|
||||
echo -e "\n${YELLOW}运行测试: ${test_name}${NC}" >&2
|
||||
|
||||
local start_time=$(date +%s)
|
||||
local exit_code=0
|
||||
|
||||
if [[ -n "${PODMAN_SOCK}" ]] && [[ -S "${PODMAN_SOCK_PATH}" ]]; then
|
||||
export DOCKER_HOST="${PODMAN_SOCK}"
|
||||
@@ -133,27 +132,34 @@ run_test() {
|
||||
export JNA_TMPDIR="${JNA_TMP_DIR}"
|
||||
export JAVA_IO_TMPDIR="${JAVA_TMP_DIR}"
|
||||
|
||||
# 使用临时文件捕获mvn输出,避免stdout被命令替换捕获
|
||||
local mvn_output_file="${TMP_DIR}/mvn-output.tmp"
|
||||
mvn -B test -Dtest="${test_class}" \
|
||||
-Djna.tmpdir="${JNA_TMP_DIR}" \
|
||||
-Djava.io.tmpdir="${JAVA_TMP_DIR}" \
|
||||
-Dmigration.test.strict=true \
|
||||
-Dsurefire.failIfNoSpecifiedTests=true \
|
||||
2>&1 | tee "${evidence_path}" || exit_code=$?
|
||||
> "${mvn_output_file}" 2>&1
|
||||
local test_exit_code=$?
|
||||
|
||||
# tee复制到证据文件
|
||||
tee "${evidence_path}" < "${mvn_output_file}" > /dev/null
|
||||
rm -f "${mvn_output_file}"
|
||||
|
||||
local end_time=$(date +%s)
|
||||
local duration=$((end_time - start_time))
|
||||
|
||||
local result
|
||||
if [[ ${exit_code} -eq 0 ]]; then
|
||||
if [[ ${test_exit_code} -eq 0 ]]; then
|
||||
result="PASS"
|
||||
else
|
||||
result="FAIL"
|
||||
fi
|
||||
|
||||
echo -e "${result}: ${test_name} (${duration}s)"
|
||||
echo -e "${result}: ${test_name} (${duration}s)" >&2
|
||||
|
||||
# 只输出证据路径到stdout,不输出其他内容
|
||||
echo "${evidence_path}"
|
||||
# 返回退出码和证据路径,用冒号分隔
|
||||
printf '%s:%s\n' "${test_exit_code}" "${evidence_path}"
|
||||
}
|
||||
|
||||
# 主流程
|
||||
@@ -181,21 +187,26 @@ main() {
|
||||
|
||||
for test_spec in "${TEST_CLASSES[@]}"; do
|
||||
IFS='#' read -r test_class test_method <<< "${test_spec}"
|
||||
local evidence_path
|
||||
local test_result
|
||||
|
||||
if [[ -n "${test_method}" ]]; then
|
||||
evidence_path=$(run_test "${test_spec}" "${test_class}#${test_method}")
|
||||
test_result="$(run_test "${test_spec}" "${test_class}#${test_method}")"
|
||||
else
|
||||
evidence_path=$(run_test "${test_spec}" "${test_class}")
|
||||
test_result="$(run_test "${test_spec}" "${test_class}")"
|
||||
fi
|
||||
|
||||
if grep -q "BUILD SUCCESS" "${evidence_path}" 2>/dev/null; then
|
||||
# 解析退出码和证据路径
|
||||
local test_exit_code="${test_result%%:*}"
|
||||
local evidence_path="${test_result#*:}"
|
||||
|
||||
if [[ ${test_exit_code} -eq 0 ]]; then
|
||||
add_check_result "${test_spec}" "PASS" "${evidence_path}" ""
|
||||
((passed_count++))
|
||||
passed_count=$((passed_count + 1))
|
||||
else
|
||||
local details=$(tail -50 "${evidence_path}" 2>/dev/null || echo "无日志")
|
||||
local details
|
||||
details="$(tail -50 "${evidence_path}" 2>/dev/null || echo "无日志")"
|
||||
add_check_result "${test_spec}" "FAIL" "${evidence_path}" "${details}"
|
||||
((failed_count++))
|
||||
failed_count=$((failed_count + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -208,11 +219,11 @@ main() {
|
||||
|
||||
if [[ ${build_exit_code} -eq 0 ]]; then
|
||||
add_check_result "Maven构建" "PASS" "${build_log}" ""
|
||||
((passed_count++))
|
||||
passed_count=$((passed_count + 1))
|
||||
else
|
||||
local details=$(tail -50 "${build_log}" 2>/dev/null || echo "无日志")
|
||||
add_check_result "Maven构建" "FAIL" "${build_log}" "${details}"
|
||||
((failed_count++))
|
||||
failed_count=$((failed_count + 1))
|
||||
fi
|
||||
|
||||
# 生成总结
|
||||
|
||||
Reference in New Issue
Block a user