-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapt unit tests #9
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ find_package(everest-cmake 0.1 REQUIRED | |
# | ||
option(BUILD_EXAMPLES "enable building of examples" OFF) | ||
option(FSM_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT}) | ||
|
||
option(${PROJECT_NAME}_BUILD_TESTING "Build unit tests, used if included as dependency" OFF) | ||
option(BUILD_TESTING "Build unit tests, used if standalone project" OFF) | ||
|
||
# | ||
# library declaration | ||
|
@@ -39,8 +40,9 @@ endif() | |
# | ||
# tests | ||
# | ||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) | ||
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING) | ||
include(CTest) | ||
enable_testing() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://cmake.org/cmake/help/latest/command/enable_testing.html should not be necessary as we're requiring There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed
andistorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
add_subdirectory(tests) | ||
endif() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,20 +16,21 @@ if (CODE_COVERAGE) | |
evc_include(CodeCoverage) | ||
endif() | ||
|
||
add_executable(test_state_allocator state_allocator.cpp) | ||
target_link_libraries(test_state_allocator | ||
set(TEST_TARGET_NAME ${PROJECT_NAME}_tests) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other repos we re-use that TEST_TARGET_NAME variable for multiple test cases, so setting it to something like set(TEST_TARGET_NAME ${PROJECT_NAME}_state_allocator_tests) and later set(TEST_TARGET_NAME ${PROJECT_NAME}_some_other_target_name_tests) If we just use a |
||
add_executable(${TEST_TARGET_NAME} state_allocator.cpp) | ||
target_link_libraries(${TEST_TARGET_NAME} | ||
PRIVATE | ||
fsm::fsm | ||
Catch2::Catch2WithMain | ||
) | ||
|
||
if (CODE_COVERAGE) | ||
append_coverage_compiler_flags_to_target(test_state_allocator) | ||
append_coverage_compiler_flags_to_target(${TEST_TARGET_NAME}) | ||
setup_target_for_coverage_gcovr_html( | ||
NAME coverage | ||
EXECUTABLE test_state_allocator | ||
EXECUTABLE ${TEST_TARGET_NAME} | ||
BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/include" | ||
) | ||
endif() | ||
|
||
catch_discover_tests(test_state_allocator) | ||
catch_discover_tests(${TEST_TARGET_NAME}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about the
... AND BUILD_TESTING
here, if this is required, we probably will also trigger building tests in our external requirements like libcurl and maybe othersThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is the result of the discussion here: EVerest/EVerest#129 and and in the
WG CI/CD & Testing
.I understand your concern, could be handled by using the
options
field independencies.yaml
(settingBUILD_TESTING=OFF
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has the discussion, you mentioned, taken into account, that requiring
BUILD_TESTING
would trigger unit tests in the dependencies?Concerning the setting
BUILD_TESTING
in the options field - I'm not sure if this will work - because it is an option with global scope. So it can be only on or off, but not on for one project and off for another one.