Skip to content

Commit 6c89931

Browse files
committed
test: discover gtest tests at ctest startup, not POST_BUILD
CMake 4.4.0's generated discovery scripts omit TEST_TARGET, so every target's POST_BUILD discovery shares one JSON file (cmake_test_discovery_e3b0c44298.json, sha256 of the empty string). Ninja links test binaries in parallel and their discovery steps race on that file: one truncates it while another parses, producing the intermittent macOS failure ParseTestList.cmake:96: string sub-command JSON failed parsing json string ... Line 1, Column 1: Syntax error Fixed upstream in cmake 4.4.1, but Homebrew CI runners ship 4.4.0. PRE_TEST discovery runs serially at ctest startup, immune to the race on any cmake version. Measured cost: 0.8s to enumerate all 772 tests, cached thereafter (0.12s); build step drops its ~28 post-link discovery executions.
1 parent 4915b55 commit 6c89931

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
find_package(GTest REQUIRED CONFIG)
22
include(GoogleTest)
33

4+
# Discover tests at ctest startup (serial) instead of POST_BUILD (parallel).
5+
# Parallel POST_BUILD discovery races on a shared JSON file under cmake 4.4.0,
6+
# intermittently failing macOS builds with "JSON failed parsing".
7+
set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST)
8+
49
add_library(moqx_test_utils STATIC
510
TestUtils.cpp
611
)

0 commit comments

Comments
 (0)