test: 补充 dde-launchpad 单元测试 - #813
MyLeeJiEun wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MyLeeJiEun The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @MyLeeJiEun. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideThis PR substantially expands dde-launchpad’s Qt6 unit-test coverage across core models and utilities, integrates 15 CTest targets through the BUILD_TESTING option, and instruments test-linked object libraries to support an aggregate lcov coverage workflow. Flow diagram for Qt6 test and coverage executionflowchart LR
Configure["cmake -B build -DBUILD_TESTING=ON"] --> Build["cmake --build build"]
Build --> CTest["ctest --test-dir build --output-on-failure"]
CTest --> Coverage["lcov filtered coverage report"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="CMakeLists.txt" line_range="9" />
<code_context>
project(dde-launchpad VERSION 0.7.0)
-option(BUILD_TEST "Whether or not to build the tests" OFF)
+option(BUILD_TESTING "Whether or not to build the tests" OFF)
option(CMAKE_EXPORT_COMPILE_COMMANDS "clangd support" ON)
</code_context>
<issue_to_address>
**issue (broader_impact):** Existing invocations that configure the project with `-DBUILD_TEST=ON` no longer build or register any tests because the old option is silently ignored and the new condition checks only `BUILD_TESTING`. This contradicts the documented verification command in the change description and breaks downstream CI or packaging scripts that still use the old option.
**Triggers:** When a caller continues to pass the previous `BUILD_TEST` option.
**Suggested fix:** Preserve a compatibility alias from `BUILD_TEST` to `BUILD_TESTING`, or update every supported build invocation and fail clearly when the deprecated option is used.
```suggestion
option(BUILD_TESTING "Whether or not to build the tests" OFF)
option(BUILD_TEST "Deprecated alias for BUILD_TESTING" OFF)
if(BUILD_TEST)
set(BUILD_TESTING ON)
endif()
```
</issue_to_address>
### Comment 2
<location path="tests/CMakeLists.txt" line_range="123-143" />
<code_context>
+find_program(GENHTML_BIN genhtml)
+set(_run_test_coverage "")
+if(LCOV_BIN AND GENHTML_BIN)
+ set(_run_test_coverage
+ COMMAND ${LCOV_BIN} --capture --directory ${CMAKE_BINARY_DIR}
+ --rc lcov_branch_coverage=1 --output-file ${CMAKE_BINARY_DIR}/coverage.info
+ COMMAND ${LCOV_BIN} --extract ${CMAKE_BINARY_DIR}/coverage.info
+ --rc lcov_branch_coverage=1
+ "${CMAKE_SOURCE_DIR}/src/models/*"
+ "${CMAKE_SOURCE_DIR}/src/utils/*"
+ "${CMAKE_SOURCE_DIR}/src/gioutils/*"
+ --output-file ${CMAKE_BINARY_DIR}/coverage_filtered.info
+ COMMAND ${GENHTML_BIN} ${CMAKE_BINARY_DIR}/coverage_filtered.info
+ --branch-coverage --output-directory ${CMAKE_BINARY_DIR}/coverage_report
+ )
+endif()
+add_custom_target(coverage
</code_context>
<issue_to_address>
**issue (bug_risk):** The `coverage` target succeeds after running the tests without generating any report when either `lcov` or `genhtml` is unavailable, because `_run_test_coverage` is left empty and no failure or warning is emitted. Consumers therefore receive a green coverage build with the promised `coverage_report/index.html` missing.
**Triggers:** When lcov or genhtml is not installed on the build host.
**Suggested fix:** Make the coverage target fail with a clear dependency error, or explicitly report that coverage generation was skipped instead of presenting the target as successful.
</issue_to_address>| set(_run_test_coverage | ||
| COMMAND ${LCOV_BIN} --capture --directory ${CMAKE_BINARY_DIR} | ||
| --rc lcov_branch_coverage=1 --output-file ${CMAKE_BINARY_DIR}/coverage.info | ||
| COMMAND ${LCOV_BIN} --extract ${CMAKE_BINARY_DIR}/coverage.info | ||
| --rc lcov_branch_coverage=1 | ||
| "${CMAKE_SOURCE_DIR}/src/models/*" | ||
| "${CMAKE_SOURCE_DIR}/src/utils/*" | ||
| "${CMAKE_SOURCE_DIR}/src/gioutils/*" | ||
| --output-file ${CMAKE_BINARY_DIR}/coverage_filtered.info | ||
| COMMAND ${GENHTML_BIN} ${CMAKE_BINARY_DIR}/coverage_filtered.info | ||
| --branch-coverage --output-directory ${CMAKE_BINARY_DIR}/coverage_report | ||
| ) | ||
| endif() | ||
| add_custom_target(coverage | ||
| COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure | ||
| ${_run_test_coverage} | ||
| DEPENDS ${LAUNCHPAD_TEST_TARGETS} | ||
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| COMMENT "Run all tests and generate coverage report" | ||
| VERBATIM | ||
| ) |
There was a problem hiding this comment.
issue (bug_risk): The coverage target succeeds after running the tests without generating any report when either lcov or genhtml is unavailable, because _run_test_coverage is left empty and no failure or warning is emitted. Consumers therefore receive a green coverage build with the promised coverage_report/index.html missing.
Triggers: When lcov or genhtml is not installed on the build host.
Suggested fix: Make the coverage target fail with a clear dependency error, or explicitly report that coverage generation was skipped instead of presenting the target as successful.
ddcced3 to
43f1b2a
Compare
43f1b2a to
738b51c
Compare
738b51c to
9f56913
Compare
|
ci没过, |
9f56913 to
14f5896
Compare
|
1. Add 14 Qt6 unit test files covering models and utils modules 2. Expand existing itemspage and searchfilter proxy model tests 3. Update CMakeLists.txt to register new targets with gcov coverage 4. Achieve 72.0% filtered line coverage and 86.1% function coverage Influence: 1. Build with cmake -DBUILD_TEST=ON and run all 15 test targets 2. Verify 185 test cases pass with zero failures 3. Check gcov coverage report for src/models and src/utils 4. Validate test isolation with no false-green cases test: 补充 dde-launchpad 单元测试 185 用例 1. 新增 14 个 Qt6 单元测试文件覆盖 models 和 utils 模块 2. 扩展已有的 itemspage 和 searchfilter 代理模型测试 3. 更新 CMakeLists.txt 注册新测试 target 并启用 gcov 覆盖率 4. 达到 72.0% 过滤后行覆盖率和 86.1% 函数覆盖率 Influence: 1. 使用 cmake -DBUILD_TEST=ON 编译并运行全部 15 个测试 target 2. 验证 185 条用例全部通过零失败 3. 检查 src/models 和 src/utils 模块的 gcov 覆盖率报告 4. 验证测试隔离性无 false-green 用例
1. Rename the test gate option from BUILD_TEST to BUILD_TESTING 2. Enable coverage instrumentation for test targets by default 3. Add coverage target that runs ctest and generates the lcov report Log: Unify the test gate to BUILD_TESTING and add a coverage target test: 统一测试门控为 BUILD_TESTING 并新增 coverage 目标 1. 将测试门控选项由 BUILD_TEST 重命名为 BUILD_TESTING 2. 默认开启测试目标的覆盖率插桩 3. 新增 coverage 目标,执行 ctest 并生成 lcov 报告 Log: 统一测试门控为 BUILD_TESTING,并新增 coverage 目标
14f5896 to
0a3396f
Compare
|
TAG Bot New tag: 2.0.48 |
补充 dde-launchpad 单元测试
关联 Multica 任务: DDE-109 (补充 dde-launchpad 项目测试代码)
变更内容
src/models和src/utils核心模块itemspage和searchfilter代理模型测试tests/CMakeLists.txt,注册全部 15 个测试 target 并启用 gcov 覆盖率编译选项测试与覆盖率
验证方式
Summary by Sourcery
Expand dde-launchpad’s automated Qt6 test coverage and provide an integrated CTest coverage workflow for its core models and utilities.
Enhancements:
Build:
Tests: