Skip to content

fix: skip unit tests in Release build for packaging - #597

Open
pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/bug/ed988976d849
Open

pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/bug/ed988976d849

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

fix: skip unit tests in Release build for packaging

  1. Root cause: BUILD_TESTS option defaulted ON regardless of
    CMAKE_BUILD_TYPE, Release packaging builds compiled and ran
    unit tests via gtest_discover_tests which timed out on aarch64
    under high parallelism (make -j96) due to Qt6 WebEngine shared
    library loading exceeding the 5s default DISCOVERY_TIMEOUT
  2. Fix: guard BUILD_TESTS with CMAKE_BUILD_TYPE check to skip
    tests in Release mode; add DISCOVERY_TIMEOUT 30 to all
    gtest_discover_tests calls as Debug-mode defensive measure
  3. Impact: Release packaging builds no longer compile or run unit
    tests, eliminating the timeout; Debug builds retain full test
    coverage with extended discovery timeout

Influence:

  1. Verify Release mode packaging build completes without timeout
  2. Verify Debug mode unit tests still run with DISCOVERY_TIMEOUT 30
  3. Confirm no test targets are missing DISCOVERY_TIMEOUT parameter

fix: Release模式下跳过单元测试修复打包失败

  1. 根因:BUILD_TESTS 选项默认 ON 且不检查 CMAKE_BUILD_TYPE,
    Release 打包构建编译并运行单元测试,gtest_discover_tests
    在 aarch64 高并行(make -j96)下因 Qt6 WebEngine 共享库
    加载超过 5 秒默认 DISCOVERY_TIMEOUT 而超时
  2. 方案:BUILD_TESTS 增加 CMAKE_BUILD_TYPE 检查,Release 模式
    跳过测试;所有 gtest_discover_tests 调用添加
    DISCOVERY_TIMEOUT 30 作为 Debug 模式防御性措施
  3. 影响:Release 打包构建不再编译运行单元测试,消除超时;
    Debug 构建保留完整测试覆盖并延长发现超时时间

Influence:

  1. 验证 Release 模式打包构建无超时完成
  2. 验证 Debug 模式单元测试在 DISCOVERY_TIMEOUT 30 下正常运行
  3. 确认所有测试目标均已添加 DISCOVERY_TIMEOUT 参数

PMS: BUG-20260918

Summary by Sourcery

Skip unit tests in Release builds and extend GoogleTest discovery timeouts to make packaging reliable while retaining Debug test coverage.

Bug Fixes:

  • Prevent Release packaging builds from compiling and running unit tests, avoiding test-discovery timeouts under high parallelism.

Enhancements:

  • Increase GoogleTest discovery timeouts to 30 seconds across all unit-test targets while preserving Debug-mode test coverage.

Build:

  • Condition unit-test configuration on the build type so tests are excluded from Release builds.

1. Root cause: BUILD_TESTS option defaulted ON regardless of
   CMAKE_BUILD_TYPE, Release packaging builds compiled and ran
   unit tests via gtest_discover_tests which timed out on aarch64
   under high parallelism (make -j96) due to Qt6 WebEngine shared
   library loading exceeding the 5s default DISCOVERY_TIMEOUT
2. Fix: guard BUILD_TESTS with CMAKE_BUILD_TYPE check to skip
   tests in Release mode; add DISCOVERY_TIMEOUT 30 to all
   gtest_discover_tests calls as Debug-mode defensive measure
3. Impact: Release packaging builds no longer compile or run unit
   tests, eliminating the timeout; Debug builds retain full test
   coverage with extended discovery timeout

Influence:
1. Verify Release mode packaging build completes without timeout
2. Verify Debug mode unit tests still run with DISCOVERY_TIMEOUT 30
3. Confirm no test targets are missing DISCOVERY_TIMEOUT parameter

fix: Release模式下跳过单元测试修复打包失败

1. 根因:BUILD_TESTS 选项默认 ON 且不检查 CMAKE_BUILD_TYPE,
   Release 打包构建编译并运行单元测试,gtest_discover_tests
   在 aarch64 高并行(make -j96)下因 Qt6 WebEngine 共享库
   加载超过 5 秒默认 DISCOVERY_TIMEOUT 而超时
2. 方案:BUILD_TESTS 增加 CMAKE_BUILD_TYPE 检查,Release 模式
   跳过测试;所有 gtest_discover_tests 调用添加
   DISCOVERY_TIMEOUT 30 作为 Debug 模式防御性措施
3. 影响:Release 打包构建不再编译运行单元测试,消除超时;
   Debug 构建保留完整测试覆盖并延长发现超时时间

Influence:
1. 验证 Release 模式打包构建无超时完成
2. 验证 Debug 模式单元测试在 DISCOVERY_TIMEOUT 30 下正常运行
3. 确认所有测试目标均已添加 DISCOVERY_TIMEOUT 参数

PMS: BUG-20260918

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Release builds now skip configuring unit tests to avoid Qt6 WebEngine/gtest discovery timeouts during packaging, while Debug builds retain full test coverage with a 30-second discovery timeout across all test targets.

Sequence diagram for Release packaging build

sequenceDiagram
    participant Packager
    participant CMake
    participant Tests
    participant Package
    Packager->>CMake: configure Release build
    CMake->>CMake: evaluate BUILD_TESTS AND NOT CMAKE_BUILD_TYPE STREQUAL Release
    CMake-->>Packager: skip add_subdirectory tests
    Packager->>Package: build packaging artifacts
    Package-->>Packager: complete without test discovery timeout
Loading

Sequence diagram for Debug unit test discovery

sequenceDiagram
    participant Developer
    participant CMake
    participant Tests
    participant GTest
    Developer->>CMake: configure Debug build
    CMake->>Tests: add_subdirectory tests
    Tests->>GTest: gtest_discover_tests with DISCOVERY_TIMEOUT 30
    GTest-->>Tests: discover unit tests
    Tests-->>Developer: run full unit test coverage
Loading

Flow diagram for build-mode test selection

flowchart TD
    A[CMake configure] --> B{BUILD_TESTS enabled?}
    B -->|No| C[Configure application only]
    B -->|Yes| D{CMAKE_BUILD_TYPE is Release?}
    D -->|Yes| C
    D -->|No| E[add_subdirectory tests]
    E --> F[Build and run unit tests]
    F --> G[gtest_discover_tests with DISCOVERY_TIMEOUT 30]
Loading

File-Level Changes

Change Details Files
Restrict test-subdirectory configuration to non-Release builds.
  • Keep the existing BUILD_TESTS option while adding a CMAKE_BUILD_TYPE guard.
  • Prevent Release packaging configurations from creating, compiling, or running unit-test targets.
CMakeLists.txt
Increase GoogleTest discovery tolerance for retained test builds.
  • Set DISCOVERY_TIMEOUT to 30 seconds on every gtest_discover_tests invocation.
  • Preserve the offscreen Qt environment and existing Debug coverage linkage.
tests/app_ut/CMakeLists.txt
tests/common/CMakeLists.txt
tests/common2/CMakeLists.txt
tests/controls_ut/CMakeLists.txt
tests/daemon_ut/CMakeLists.txt
tests/editor_areas/CMakeLists.txt
tests/editor_core/CMakeLists.txt
tests/editor_markdown/CMakeLists.txt
tests/editor_undo/CMakeLists.txt
tests/editor_wrapper/CMakeLists.txt
tests/startmanager/CMakeLists.txt
tests/thememodule/CMakeLists.txt
tests/widgets_ut/CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-bot

deepin-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.6.4
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants