fix(tests): avoid core boot during gtest discovery timeout#160
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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_TESTso discovery happens atctesttime 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.
📊 liblogos doc-test reportThe 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 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI builds fail with a wall of
dependency failederrors ending atrun-logos-standalone-ui, but that's just the cascade — the real failure is insidelogos-liblogos. The C++ compiles and links fine and all build steps pass; it dies one step later in CMake test discovery withProcess terminated due to timeoutand empty output. Deterministic (reproduces identically every run).Root cause
tests/CMakeLists.txtusedgtest_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_testsat build time just to enumerate tests.But
tests/test_app_lifecycle.cpp'smain()calledlogos_core_init(argc, argv)before::testing::InitGoogleTest():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)
tests/CMakeLists.txt—gtest_discover_tests(logos_core_tests DISCOVERY_MODE PRE_TEST). Defers enumeration toctesttime so the binary never runs during the Nix build. This alone deterministically fixes the failure.tests/test_app_lifecycle.cpp— runInitGoogleTestfirst and return early when only listing tests, beforelogos_core_init(). Correctness safety-net so listing never boots the core regardless of discovery mode.Validation
ws test logos-liblogos --auto-local→ PASS. Sails past discovery; the full chain (lib → bin → standalone-app) builds green when pointed at this branch via--override-input.🤖 Generated with Claude Code