From 25b13eeead9800616ce0971a8c71db2df4d90e87 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Fri, 5 Jun 2026 13:26:20 -0400 Subject: [PATCH] feat(profiling): add INSTALL_SUBDIR keyword to dd_wrapper_add_test Allows version-specific native test binaries to install into a subdir of the shared test/ directory (e.g. INSTALL_SUBDIR py315 -> test/py315/). build_base_venvs runs in parallel across all Python versions and GitLab merges all artifacts into a single directory for downstream jobs. Without isolation a binary compiled for pyX.Y (RPATH -> libpythonX.Y) lands in the shared test/ directory and crashes when the pytest gtest plugin tries to run it against a different Python runtime. Callers that do not pass INSTALL_SUBDIR are unaffected. Co-Authored-By: Claude Sonnet 4.6 --- .../datadog/profiling/stack/test/CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/stack/test/CMakeLists.txt b/ddtrace/internal/datadog/profiling/stack/test/CMakeLists.txt index e00be5e90a1..face972eb7b 100644 --- a/ddtrace/internal/datadog/profiling/stack/test/CMakeLists.txt +++ b/ddtrace/internal/datadog/profiling/stack/test/CMakeLists.txt @@ -36,7 +36,12 @@ if(DO_VALGRIND) endif() function(dd_wrapper_add_test name) - add_executable(${name} ${ARGN}) + # Optional keyword argument: INSTALL_SUBDIR Installs the test binary to test// instead of test/. Use for + # version-specific binaries (e.g. INSTALL_SUBDIR py315) to prevent CI artifact collisions when build_base_venvs runs + # in parallel across Python versions and GitLab merges all artifacts into a shared directory. + cmake_parse_arguments(_ARG "" "INSTALL_SUBDIR" "" ${ARGN}) + set(_SOURCES ${_ARG_UNPARSED_ARGUMENTS}) + add_executable(${name} ${_SOURCES}) target_include_directories(${name} PRIVATE ../include) # this has to refer to the stack extension name to properly link against target_link_libraries(${name} PRIVATE gmock gtest_main ${EXTENSION_NAME}) @@ -72,7 +77,11 @@ function(dd_wrapper_add_test name) endif() if(LIB_INSTALL_DIR) - install(TARGETS ${name} RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../test) + if(_ARG_INSTALL_SUBDIR) + install(TARGETS ${name} RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../test/${_ARG_INSTALL_SUBDIR}) + else() + install(TARGETS ${name} RUNTIME DESTINATION ${LIB_INSTALL_DIR}/../test) + endif() endif() endfunction()