From af040955abd5d63e99b0dd3b018a16757ef14661 Mon Sep 17 00:00:00 2001 From: Ramakrishna Prabhu Date: Thu, 8 Oct 2026 16:33:54 -0500 Subject: [PATCH 1/3] Install a relocatable CTestTestfile.cmake for the packaged C++ tests Switches ConfigureTest and the remaining hand-rolled add_test() call sites to rapids_test_add(), and adds rapids_test_install_relocatable() so the libcuopt-tests conda package ships a working CTestTestfile.cmake, matching cudf's approach. run_ctests.sh is untouched -- it still execs the raw binaries it always has. This only adds the ability to run `ctest` directly against the installed package; a later PR will use that (via `ctest -L`) to let CI skip routing's test binaries when a PR doesn't touch routing. --- ci/test_cpp.sh | 7 +++++++ cpp/tests/CMakeLists.txt | 13 +++++++++++-- cpp/tests/linear_programming/CMakeLists.txt | 2 +- cpp/tests/linear_programming/grpc/CMakeLists.txt | 11 ++++++++--- cpp/tests/routing/grpc/CMakeLists.txt | 6 ++++-- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 8f3c2c4fa7..7b11185630 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -31,6 +31,13 @@ mkdir -p "${RAPIDS_TESTS_DIR}" rapids-print-env +# TEMPORARY: verify rapids_test_install_relocatable actually produced a working +# CTestTestfile.cmake in the installed package. Not used by run_ctests.sh yet +# (that lands in a later PR) -- this just proves the plumbing before merge. +# Revert before merge. +rapids-logger "Verify ctest registry was installed" +ctest --test-dir "${CONDA_PREFIX}/bin/gtests/libcuopt" -N + rapids-logger "Check GPU usage" nvidia-smi diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 8696be791d..76db000434 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -123,7 +123,7 @@ function(ConfigureTest CMAKE_TEST_NAME) if(NOT DEFINED INSTALL_TARGET OR "${INSTALL_TARGET}" STREQUAL "") target_link_options(${CMAKE_TEST_NAME} PRIVATE -Wl,--enable-new-dtags) endif() - add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) + rapids_test_add(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME} INSTALL_COMPONENT_SET testing) if(CT_LABELS) set_tests_properties(${CMAKE_TEST_NAME} PROPERTIES LABELS "${CT_LABELS}") endif() @@ -147,6 +147,15 @@ endif(RAPIDS_DATASET_ROOT_DIR) # ## test sources if(BUILD_TESTS) + # Must run before any ConfigureTest/rapids_test_add call in the subdirectories below: + # rapids_test_add records each test against the install component set rapids_test_init() + # creates, and rapids_test_install_relocatable (after the subdirectories) packages that + # record into an installable CTestTestfile.cmake so `ctest` works against the conda + # package directly, not just the build tree. + enable_testing() + include(rapids-test) + rapids_test_init() + if(NOT SKIP_ROUTING_BUILD) add_subdirectory(routing) add_subdirectory(distance_engine) @@ -160,5 +169,5 @@ if(BUILD_TESTS) add_subdirectory(qp) add_subdirectory(utilities) - enable_testing() + rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/libcuopt) endif() diff --git a/cpp/tests/linear_programming/CMakeLists.txt b/cpp/tests/linear_programming/CMakeLists.txt index e2c347913c..2d61ff0d2e 100644 --- a/cpp/tests/linear_programming/CMakeLists.txt +++ b/cpp/tests/linear_programming/CMakeLists.txt @@ -90,7 +90,7 @@ if (NOT SKIP_C_PYTHON_ADAPTERS) target_link_options(C_API_TEST PRIVATE -Wl,--enable-new-dtags) endif() - add_test(NAME C_API_TEST COMMAND C_API_TEST) + rapids_test_add(NAME C_API_TEST COMMAND C_API_TEST INSTALL_COMPONENT_SET testing) set_tests_properties(C_API_TEST PROPERTIES LABELS "numopt") install( diff --git a/cpp/tests/linear_programming/grpc/CMakeLists.txt b/cpp/tests/linear_programming/grpc/CMakeLists.txt index 7bcac7634f..132b8276e5 100644 --- a/cpp/tests/linear_programming/grpc/CMakeLists.txt +++ b/cpp/tests/linear_programming/grpc/CMakeLists.txt @@ -44,7 +44,7 @@ if(NOT DEFINED INSTALL_TARGET OR "${INSTALL_TARGET}" STREQUAL "") target_link_options(GRPC_CLIENT_TEST PRIVATE -Wl,--enable-new-dtags) endif() -add_test(NAME GRPC_CLIENT_TEST COMMAND GRPC_CLIENT_TEST) +rapids_test_add(NAME GRPC_CLIENT_TEST COMMAND GRPC_CLIENT_TEST INSTALL_COMPONENT_SET testing) set_tests_properties(GRPC_CLIENT_TEST PROPERTIES LABELS "numopt") install( @@ -86,7 +86,8 @@ if(NOT DEFINED INSTALL_TARGET OR "${INSTALL_TARGET}" STREQUAL "") target_link_options(GRPC_PIPE_SERIALIZATION_TEST PRIVATE -Wl,--enable-new-dtags) endif() -add_test(NAME GRPC_PIPE_SERIALIZATION_TEST COMMAND GRPC_PIPE_SERIALIZATION_TEST) +rapids_test_add(NAME GRPC_PIPE_SERIALIZATION_TEST COMMAND GRPC_PIPE_SERIALIZATION_TEST + INSTALL_COMPONENT_SET testing) set_tests_properties(GRPC_PIPE_SERIALIZATION_TEST PROPERTIES LABELS "numopt") install( @@ -137,11 +138,15 @@ endif() # Integration tests need the server binary to be built first add_dependencies(GRPC_INTEGRATION_TEST cuopt_grpc_server) -add_test( +rapids_test_add( NAME GRPC_INTEGRATION_TEST COMMAND ${CMAKE_COMMAND} -E env "CUOPT_GRPC_SERVER_PATH=$" $ + # The COMMAND's first token is cmake itself, not the test target, so + # rapids_test_add can't infer what to install -- name it explicitly. + INSTALL_COMPONENT_SET testing + INSTALL_TARGET GRPC_INTEGRATION_TEST ) set_tests_properties(GRPC_INTEGRATION_TEST PROPERTIES LABELS "numopt") diff --git a/cpp/tests/routing/grpc/CMakeLists.txt b/cpp/tests/routing/grpc/CMakeLists.txt index a8c56ae79f..98e0bd9500 100644 --- a/cpp/tests/routing/grpc/CMakeLists.txt +++ b/cpp/tests/routing/grpc/CMakeLists.txt @@ -64,7 +64,8 @@ if(NOT DEFINED INSTALL_TARGET OR "${INSTALL_TARGET}" STREQUAL "") target_link_options(GRPC_ROUTING_PROBLEM_MAPPER_TEST PRIVATE -Wl,--enable-new-dtags) endif() -add_test(NAME GRPC_ROUTING_PROBLEM_MAPPER_TEST COMMAND GRPC_ROUTING_PROBLEM_MAPPER_TEST) +rapids_test_add(NAME GRPC_ROUTING_PROBLEM_MAPPER_TEST COMMAND GRPC_ROUTING_PROBLEM_MAPPER_TEST + INSTALL_COMPONENT_SET testing) set_tests_properties(GRPC_ROUTING_PROBLEM_MAPPER_TEST PROPERTIES LABELS "routing") # Settings mapper round-trip (no running server). This mapper reads @@ -96,7 +97,8 @@ if(NOT DEFINED INSTALL_TARGET OR "${INSTALL_TARGET}" STREQUAL "") target_link_options(GRPC_ROUTING_SETTINGS_MAPPER_TEST PRIVATE -Wl,--enable-new-dtags) endif() -add_test(NAME GRPC_ROUTING_SETTINGS_MAPPER_TEST COMMAND GRPC_ROUTING_SETTINGS_MAPPER_TEST) +rapids_test_add(NAME GRPC_ROUTING_SETTINGS_MAPPER_TEST COMMAND GRPC_ROUTING_SETTINGS_MAPPER_TEST + INSTALL_COMPONENT_SET testing) set_tests_properties(GRPC_ROUTING_SETTINGS_MAPPER_TEST PROPERTIES LABELS "routing") install( From dd6280665c117e21df3fd547d0643433d22bebae Mon Sep 17 00:00:00 2001 From: Ramakrishna Prabhu Date: Thu, 8 Oct 2026 18:27:21 -0500 Subject: [PATCH 2/3] TEMPORARY: install cmake for the ctest verification step --- ci/test_cpp.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 7b11185630..e420508149 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -36,6 +36,9 @@ rapids-print-env # (that lands in a later PR) -- this just proves the plumbing before merge. # Revert before merge. rapids-logger "Verify ctest registry was installed" +# The 'test' env only has runtime deps; ctest ships with cmake, which it doesn't need +# otherwise. Install it only for this throwaway check. +rapids-mamba-retry install --yes -n test cmake ctest --test-dir "${CONDA_PREFIX}/bin/gtests/libcuopt" -N rapids-logger "Check GPU usage" From cb06cc97edd3c8cbe999c8f01ba822c816b5bab5 Mon Sep 17 00:00:00 2001 From: Ramakrishna Prabhu Date: Thu, 8 Oct 2026 20:07:19 -0500 Subject: [PATCH 3/3] Revert TEMPORARY ctest verification step Confirmed in CI across all 8 conda-cpp-tests matrix entries (V100, A100, 2x H100, 2x L4, RTX Pro 6000): 'ctest -N' lists all 23 registered tests against the installed libcuopt-tests package, and the existing gtest suite (unmodified run_ctests.sh) still passes cleanly. ci/test_cpp.sh is now byte-identical to main. --- ci/test_cpp.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index e420508149..8f3c2c4fa7 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -31,16 +31,6 @@ mkdir -p "${RAPIDS_TESTS_DIR}" rapids-print-env -# TEMPORARY: verify rapids_test_install_relocatable actually produced a working -# CTestTestfile.cmake in the installed package. Not used by run_ctests.sh yet -# (that lands in a later PR) -- this just proves the plumbing before merge. -# Revert before merge. -rapids-logger "Verify ctest registry was installed" -# The 'test' env only has runtime deps; ctest ships with cmake, which it doesn't need -# otherwise. Install it only for this throwaway check. -rapids-mamba-retry install --yes -n test cmake -ctest --test-dir "${CONDA_PREFIX}/bin/gtests/libcuopt" -N - rapids-logger "Check GPU usage" nvidia-smi