Skip to content

Commit

Permalink
Separate CUB's catch2 test binaries by default for CI. (#1482)
Browse files Browse the repository at this point in the history
* Build/run all catch2 tests separated to debug timeouts.

* Trivial change to common catch2 header to trigger uncached rebuild.

* Move the Catch2 main TUs into an object library for separated test builds.
  • Loading branch information
alliepiper authored Mar 6, 2024
1 parent b049a69 commit b22d759
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
"CCCL_ENABLE_CUB": true,
"CUB_ENABLE_TESTING": true,
"CUB_ENABLE_EXAMPLES": true,
"CUB_SEPARATE_CATCH2": true,
"CUB_ENABLE_DIALECT_CPP11": false,
"CUB_ENABLE_DIALECT_CPP14": false,
"CUB_ENABLE_DIALECT_CPP17": false,
Expand Down
8 changes: 7 additions & 1 deletion cub/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,14 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
endif() # config_c2h_target

if (CUB_SEPARATE_CATCH2)
set(catch2_main_objects ${config_prefix}.catch2_main_objects)
if (NOT TARGET ${catch2_main_objects})
add_library(${catch2_main_objects} OBJECT catch2_runner.cpp catch2_runner_helper.cu)
target_link_libraries(${catch2_main_objects} PUBLIC Catch2::Catch2)
endif()

add_executable(${test_target} "${test_src}")
target_compile_definitions(${test_target} PRIVATE "CUB_CONFIG_MAIN")
target_link_libraries(${test_target} PRIVATE ${catch2_main_objects})
add_dependencies(${config_meta_target} ${test_target})

add_test(NAME ${test_target} COMMAND "$<TARGET_FILE:${test_target}>")
Expand Down
4 changes: 2 additions & 2 deletions cub/test/catch2_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ namespace detail
template <class T>
std::vector<T> to_vec(c2h::device_vector<T> const& vec)
{
c2h::host_vector<T> tmp = vec;
return std::vector<T>{tmp.begin(), tmp.end()};
c2h::host_vector<T> temp = vec;
return std::vector<T>{temp.begin(), temp.end()};
}

template <class T>
Expand Down

0 comments on commit b22d759

Please sign in to comment.