Skip to content

fix(tests): avoid core boot during gtest discovery timeout#160

Merged
dlipicar merged 2 commits into
masterfrom
fix/gtest-discovery-timeout
Jul 1, 2026
Merged

fix(tests): avoid core boot during gtest discovery timeout#160
dlipicar merged 2 commits into
masterfrom
fix/gtest-discovery-timeout

Conversation

@dlipicar

@dlipicar dlipicar commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

CI builds fail with a wall of dependency failed errors ending at run-logos-standalone-ui, but that's just the cascade — the real failure is inside logos-liblogos. The C++ compiles and links fine and all build steps pass; it dies one step later in CMake test discovery with Process terminated due to timeout and empty output. Deterministic (reproduces identically every run).

Root cause

tests/CMakeLists.txt used gtest_discover_tests(logos_core_tests) with no options, so it defaulted to POST_BUILD discovery mode — which runs the freshly-built test binary with --gtest_list_tests at build time just to enumerate tests.

But tests/test_app_lifecycle.cpp's main() called logos_core_init(argc, argv) before ::testing::InitGoogleTest():

int main(int argc, char** argv) {
    logos_core_init(argc, argv);        // ran first, unconditionally
    ::testing::InitGoogleTest(&argc, argv);
    ...
}

So even when only listing tests, discovery booted the full Qt core (QCoreApplication + subprocess/socket/IOKit) and loaded the whole dylib closure (Qt, boost, openssl, package-manager). In the Nix sandbox that blows past the 5s TEST_DISCOVERY_TIMEOUT, the binary is killed with empty output, and the whole derivation fails.

Fix (two parts)

  1. tests/CMakeLists.txtgtest_discover_tests(logos_core_tests DISCOVERY_MODE PRE_TEST). Defers enumeration to ctest time so the binary never runs during the Nix build. This alone deterministically fixes the failure.
  2. tests/test_app_lifecycle.cpp — run InitGoogleTest first and return early when only listing tests, before logos_core_init(). Correctness safety-net so listing never boots the core regardless of discovery mode.

Validation

ws test logos-liblogos --auto-localPASS. Sails past discovery; the full chain (lib → bin → standalone-app) builds green when pointed at this branch via --override-input.

🤖 Generated with Claude Code

gtest_discover_tests defaulted to POST_BUILD discovery mode, which runs
the freshly-built logos_core_tests binary with --gtest_list_tests at build
time. test_app_lifecycle.cpp's main() called logos_core_init() before
gtest parsed its flags, so even a bare test-listing booted the full Qt
core (QCoreApplication + subprocess/socket/IOKit) and loaded the entire
dylib closure. In the Nix sandbox this blew past the 5s
TEST_DISCOVERY_TIMEOUT, killing the binary with empty output and failing
the whole derivation (cascading up to run-logos-standalone-ui).

Fix, two parts:
- CMakeLists.txt: use DISCOVERY_MODE PRE_TEST so enumeration is deferred
  to ctest time; the binary never runs during the build. This alone
  deterministically fixes the failure.
- test_app_lifecycle.cpp: run InitGoogleTest first and return early when
  only listing tests, before logos_core_init(). Safety net so listing
  never boots the core regardless of discovery mode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 1, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses CI failures caused by GoogleTest discovery timing out when test enumeration inadvertently boots the full Logos core (Qt + heavy dependencies) during CMake’s default POST_BUILD discovery.

Changes:

  • Move core initialization to occur after InitGoogleTest() and short-circuit core boot when running with --gtest_list_tests.
  • Switch CMake test discovery to DISCOVERY_MODE PRE_TEST so discovery happens at ctest time rather than during the build.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/test_app_lifecycle.cpp Reorders initialization to avoid booting the core during test listing/discovery.
tests/CMakeLists.txt Updates gtest_discover_tests to defer discovery to test time via PRE_TEST.

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

Comment thread tests/CMakeLists.txt
Comment thread tests/test_app_lifecycle.cpp
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📊 liblogos doc-test report

The real accounts module, run through a logoscore daemon built against this commit of liblogos — rendered alongside the commands actually run and their output (updated each run, commit bd34218):

Pages can take a minute to update after the run finishes.

Read the list_tests flag via GTEST_FLAG_GET(list_tests) instead of
::testing::GTEST_FLAG(list_tests). GTEST_FLAG(name) is only a plain bool
in the non-Abseil gtest build; with the Abseil flags backend it is an
absl::Flag object, so the raw macro is not portable in a boolean context.
GTEST_FLAG_GET dispatches correctly for both backends.

The macro already qualifies with ::testing:: internally, so it must be
used unqualified — prefixing it (::testing::GTEST_FLAG_GET) expands to a
doubled ::testing::::testing:: token and fails to compile.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dlipicar
dlipicar merged commit b8de686 into master Jul 1, 2026
4 checks passed
@dlipicar
dlipicar deleted the fix/gtest-discovery-timeout branch July 1, 2026 19:03
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