Skip to content

fix: prevent lmcore tests from polluting lmnet's CTest registry#4

Merged
lmshao merged 2 commits into
masterfrom
copilot/analyze-latest-commit-actions-failure
May 10, 2026
Merged

fix: prevent lmcore tests from polluting lmnet's CTest registry#4
lmshao merged 2 commits into
masterfrom
copilot/analyze-latest-commit-actions-failure

Conversation

Copilot AI commented May 10, 2026

Copy link
Copy Markdown
Contributor

问题

CI 中 macos-kqueue 任务持续因 test_time_utilsTimeUtils.SleepMs)失败:

18/25 Test #18: test_time_utils ..................***Failed
FAIL: test_time_utils.cpp:213 - Expected true but got false
[  FAILED  ] TimeUtils.SleepMs

该测试来自依赖库 lmcore,不属于 lmnet 本身。问题根源:lmnet 通过 add_subdirectory(../lmcore lmcore_build) 引入 lmcore 时,BUILD_TESTS=ON 已在 CMake 缓存中,导致 lmcore 的测试套件(包括这个在 macOS CI runner 高负载时不稳定的时序测试)也被注册到 lmnet 的 CTest 中并一并运行。

修复

add_subdirectory(../lmcore lmcore_build) 前,用普通变量(non-cache)将 BUILD_TESTS 遮蔽为 OFF。由于 add_subdirectory 创建的子作用域会继承父作用域的普通变量,lmcore 的 option(BUILD_TESTS ...) 发现变量已定义便不再修改,从而跳过 lmcore 自己的测试。add_subdirectory 返回后用 unset(BUILD_TESTS) 移除普通变量,缓存中的 ON 值重新生效,lmnet 自身的测试照常构建。

set(BUILD_TESTS OFF)            # 普通变量遮蔽缓存,子目录继承
add_subdirectory(../lmcore lmcore_build)
unset(BUILD_TESTS)              # 恢复:缓存值(ON)重新生效

此方案不使用 CACHE FORCE,不会覆盖用户的 cmake 配置。

Copilot finished work on behalf of lmshao May 10, 2026 02:49
Copilot AI requested a review from lmshao May 10, 2026 02:49
@lmshao lmshao marked this pull request as ready for review May 10, 2026 02:51
Copilot AI review requested due to automatic review settings May 10, 2026 02:51

Copilot AI 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.

Pull request overview

This PR prevents lmcore’s test suite from being registered and executed as part of lmnet’s CTest runs when lmcore is pulled in via add_subdirectory, addressing flaky CI failures caused by lmcore timing-sensitive tests on macOS.

Changes:

  • Temporarily shadows BUILD_TESTS as a non-cache variable set to OFF before adding the lmcore subdirectory.
  • Unsets the shadowing variable immediately after add_subdirectory so lmnet’s own BUILD_TESTS cache setting continues to control lmnet tests normally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lmshao lmshao merged commit 2320a6f into master May 10, 2026
10 of 12 checks passed
@lmshao lmshao deleted the copilot/analyze-latest-commit-actions-failure branch May 10, 2026 09:53
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.

3 participants