Skip to content

Commit

Permalink
[tests] Remove tests from global discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
mcopik committed Aug 8, 2023
1 parent 1c5ebd3 commit e1be0b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions cmake/AddTest.cmake
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion control-plane/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
6 changes: 3 additions & 3 deletions process/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)

Expand Down

0 comments on commit e1be0b5

Please sign in to comment.