[grade=B urn:ump:7xuqv7qt7yyvchfbwdciklpoeh2cptk4czo7637allvx45zx6rlq] fix(test): pin WORKING_DIRECTORY to CMAKE_SOURCE_DIR for triangles_unit_tests

The consensus_safety_tests reindex_reconstruction_is_explicit_and_fail_closed
test reads src/init.cpp + src/main.cpp via __FILE__-relative 3x parent_path()
traversal. CI runs 'cd build/src && ctest', so the default
CMAKE_CURRENT_BINARY_DIR resolves __FILE__ relative paths to build/src/src/init.cpp
which doesn't exist. Pinning WORKING_DIRECTORY to ${CMAKE_SOURCE_DIR} makes the
test source paths resolve correctly from any environment.

Verified locally: ctest -R triangles_unit_tests passes 1.32s from build/ after fix.
Cycle 21 fix for CI run 31058657378 failure.
This commit is contained in:
Krystie
2026-08-05 17:58:38 -07:00
parent d35aec1828
commit b13139ad19
+9
View File
@@ -670,7 +670,16 @@ if(BUILD_TESTS)
Boost::unit_test_framework
)
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}: the consensus_safety_tests
# `reindex_reconstruction_is_explicit_and_fail_closed` test reads
# src/init.cpp + src/main.cpp via __FILE__-relative path traversal
# (3x parent_path() calls). When ctest runs from build/src/ (the
# default CMAKE_CURRENT_BINARY_DIR for src/CMakeLists.txt), the
# resolved path is build/src/src/init.cpp which doesn't exist.
# Pinning WORKING_DIRECTORY to "${CMAKE_SOURCE_DIR}" makes the test
# source paths resolve correctly from any environment.
add_test(NAME triangles_unit_tests COMMAND test_triangles --log_level=test_suite)
set_tests_properties(triangles_unit_tests PROPERTIES WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
# ── Standalone chaindb equivalence tests ─────────────────────────────────
# Runs without the TestingSetup global fixture (which would otherwise