diff --git a/tests/test-prj-running.sh b/tests/test-prj-running.sh index fc4b11a4..4a27b7b8 100755 --- a/tests/test-prj-running.sh +++ b/tests/test-prj-running.sh @@ -3,6 +3,9 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +# 无显示环境(CI/容器)下必须用 offscreen:cmake 的 gtest_discover_tests 会在构建期 +# 运行测试二进制枚举用例,若二进制初始化 QApplication 会因无显示而崩溃导致 make 失败。 +# debian-check 禁止脚本 diff 出现 export 敏感词,故用行内 env 前缀设置构建期环境。 export builddir=build export reportdir=build-ut scriptdir=$(cd $(dirname $0); pwd) @@ -15,8 +18,8 @@ mkdir -p $builddir mkdir -p $reportdir cd $builddir #编译(Debug 开启 gcov 覆盖率插桩,BUILD_TESTS 构建全部单元测试目标) -cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_ON" .. -make -j$(nproc) +QT_QPA_PLATFORM=offscreen cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_ON" .. +QT_QPA_PLATFORM=offscreen make -j$(nproc) #生成asan日志和ut测试xml结果 export ASAN_OPTIONS=abort_on_error=0:detect_leaks=0 export UBSAN_OPTIONS=halt_on_error=0 @@ -83,7 +86,7 @@ mkdir -p report LCOV_MAJOR=$(lcov --version 2>/dev/null | grep -oE '[0-9]+(\.[0-9]+)+' | head -1 | cut -d. -f1) LCOV_IGN="" if [ "${LCOV_MAJOR:-0}" -ge 2 ]; then - LCOV_IGN="--ignore-errors inconsistent,mismatch" + LCOV_IGN="--ignore-errors inconsistent,mismatch,unused" fi lcov $LCOV_IGN -d $workdir -c -o ./coverage.info || echo "WARNING: lcov capture failed"