From 3e4738f156d160a0e0f990e9f6aee6d559aeebe0 Mon Sep 17 00:00:00 2001 From: Tao He Date: Fri, 1 Mar 2024 17:23:22 +0800 Subject: [PATCH] Add vineyard_llm_cache_tests target and don't install tests artifacts in ALL (#1790) Signed-off-by: Tao He --- modules/llm-cache/CMakeLists.txt | 25 ++++++++++++++++++++++++- modules/llm-cache/tests/CMakeLists.txt | 26 -------------------------- 2 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 modules/llm-cache/tests/CMakeLists.txt diff --git a/modules/llm-cache/CMakeLists.txt b/modules/llm-cache/CMakeLists.txt index 54e531a3..ec44ea74 100644 --- a/modules/llm-cache/CMakeLists.txt +++ b/modules/llm-cache/CMakeLists.txt @@ -13,4 +13,27 @@ target_link_libraries(vineyard_llm_cache PUBLIC vineyard_client vineyard_basic) install_export_vineyard_target(vineyard_llm_cache) install_vineyard_headers("${CMAKE_CURRENT_SOURCE_DIR}") -add_subdirectory(tests) +add_custom_target(vineyard_llm_cache_tests) +add_dependencies(vineyard_tests vineyard_llm_cache_tests) + +if(BUILD_VINEYARD_TESTS) + enable_testing() + file(GLOB TEST_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/tests" "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cc") + foreach(f ${TEST_FILES}) + string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${f}) + set(T_NAME ${CMAKE_MATCH_1}) + message(STATUS "Found unit_test - " ${T_NAME}) + if(BUILD_VINEYARD_TESTS_ALL) + add_executable(${T_NAME} tests/${T_NAME}.cc) + else() + add_executable(${T_NAME} EXCLUDE_FROM_ALL tests/${T_NAME}.cc) + endif() + target_link_libraries(${T_NAME} PRIVATE + vineyard_llm_cache) + if(${LIBUNWIND_FOUND}) + target_link_libraries(${T_NAME} PRIVATE ${LIBUNWIND_LIBRARIES}) + endif() + add_test(${T_NAME}, ${T_NAME}) + add_dependencies(vineyard_llm_cache_tests ${T_NAME}) + endforeach() +endif() diff --git a/modules/llm-cache/tests/CMakeLists.txt b/modules/llm-cache/tests/CMakeLists.txt deleted file mode 100644 index 8896f24c..00000000 --- a/modules/llm-cache/tests/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -enable_testing() - -macro(add_test_case testname testfile) - add_executable(${testname} ${testfile}) - - target_include_directories(${testname} PRIVATE ${GLOG_INCLUDE_DIRS}) - target_link_libraries(${testname} PRIVATE vineyard_llm_cache) - - add_test(${testname} ${testname}) - add_dependencies(vineyard_tests ${testname}) -endmacro() - -file(GLOB LLM_TEST_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "./*.cc") - -foreach(testfile ${LLM_TEST_FILES}) - string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${testfile}) - set(testname ${CMAKE_MATCH_1}) - - if(${testname} STREQUAL "gpumalloc_test" AND NOT USE_CUDA) - continue() - endif() - - message(STATUS "Found unit_test - " ${testname}) - add_test_case(${testname} ${testfile}) -endforeach() -