From e1be0b511a790e9cf39457fb346b4f1a40eb960d Mon Sep 17 00:00:00 2001 From: Marcin Copik Date: Tue, 8 Aug 2023 21:01:27 +0200 Subject: [PATCH] [tests] Remove tests from global discovery --- CMakeLists.txt | 4 ++-- cmake/AddTest.cmake | 16 +++++++++------- control-plane/CMakeLists.txt | 2 +- process/tests/CMakeLists.txt | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 101bd7a..3c61661 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,7 @@ if(PRAAS_WITH_TESTING) set(TESTS common/tests/unit/messages.cpp common/tests/unit/uuid.cpp) foreach(test ${TESTS}) - PraaS_AddTest("control-plane" test_name ${test}) + PraaS_AddTest("control-plane" test_name ${test} TRUE) add_dependencies(${test_name} common_library) target_include_directories(${test_name} PRIVATE common_library) target_link_libraries(${test_name} PRIVATE common_library) @@ -203,7 +203,7 @@ if(PRAAS_WITH_TESTING) ) foreach(test ${TESTS}) - PraaS_AddTest("praas" test_name ${test}) + PraaS_AddTest("praas" test_name ${test} FALSE) target_link_libraries(${test_name} PRIVATE common_library) target_link_libraries(${test_name} PRIVATE controller_lib) target_link_libraries(${test_name} PRIVATE praas_sdk) diff --git a/cmake/AddTest.cmake b/cmake/AddTest.cmake index fe4af79..7c72fad 100644 --- a/cmake/AddTest.cmake +++ b/cmake/AddTest.cmake @@ -1,5 +1,5 @@ -function(PraaS_AddTest component target_name test_file) +function(PraaS_AddTest component target_name test_file add_to_gtest) if(NOT PRAAS_WITH_TESTING) message(FATAL_ERROR "Tests are disabled - cannot add tests") @@ -15,12 +15,14 @@ function(PraaS_AddTest component target_name test_file) target_link_libraries(${name} PRIVATE GTest::gmock_main) # FIXME: the python path should only be set for a subset of tests - gtest_discover_tests( - ${name} - TEST_PREFIX "${component}:" - PROPERTIES ENVIRONMENT_MODIFICATION - "PYTHONPATH=path_list_append:${CMAKE_BINARY_DIR}/process" - ) + if(add_to_gtest) + gtest_discover_tests( + ${name} + TEST_PREFIX "${component}:" + PROPERTIES ENVIRONMENT_MODIFICATION + "PYTHONPATH=path_list_append:${CMAKE_BINARY_DIR}/process" + ) + endif() set(${target_name} ${name} PARENT_SCOPE) diff --git a/control-plane/CMakeLists.txt b/control-plane/CMakeLists.txt index ff7aa02..920f17f 100644 --- a/control-plane/CMakeLists.txt +++ b/control-plane/CMakeLists.txt @@ -81,7 +81,7 @@ if(PRAAS_WITH_TESTING) ) foreach(test ${TESTS}) - PraaS_AddTest("control-plane" test_name ${test}) + PraaS_AddTest("control-plane" test_name ${test} TRUE) control_plane_dependencies(${test_name}) target_link_libraries(${test_name} PRIVATE control_plane_lib) control_plane_link(${test_name}) diff --git a/process/tests/CMakeLists.txt b/process/tests/CMakeLists.txt index a904d2c..4c04736 100644 --- a/process/tests/CMakeLists.txt +++ b/process/tests/CMakeLists.txt @@ -4,7 +4,7 @@ set(TESTS unit/messages.cpp ) foreach(test ${TESTS}) - PraaS_AddTest("process" test_name ${test}) + PraaS_AddTest("process" test_name ${test} TRUE) target_link_libraries(${test_name} PRIVATE controller_lib) endforeach() @@ -21,7 +21,7 @@ set(TESTS integration/invocation.cpp ) foreach(test ${TESTS}) - PraaS_AddTest("process" test_name ${test}) + PraaS_AddTest("process" test_name ${test} TRUE) target_link_libraries(${test_name} PRIVATE controller_lib) endforeach() @@ -37,7 +37,7 @@ if(${PRAAS_WITH_SDK}) ) foreach(test ${TESTS}) - PraaS_AddTest("process" test_name ${test}) + PraaS_AddTest("process" test_name ${test} TRUE) target_link_libraries(${test_name} PRIVATE controller_lib) target_link_libraries(${test_name} PRIVATE praas_sdk)