Files
logos-liblogos/tests
Dario LipicarandClaude Opus 4.8 b8de686bce fix(tests): avoid core boot during gtest discovery timeout (#160)
* fix(tests): avoid core boot during gtest discovery timeout

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>

* fix(tests): use GTEST_FLAG_GET for list-tests guard

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>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 16:03:38 -03:00
..