diff options
author | John Thacker <johnthacker@gmail.com> | 2022-08-25 07:49:09 -0400 |
---|---|---|
committer | A Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2022-08-26 00:51:10 +0000 |
commit | b65b95dda4e2aa7983a342957ff287059225bc22 (patch) | |
tree | 71006f97e2c235505bcf3596dd98b0582df2fa18 /CMakeLists.txt | |
parent | 67ceab96c8dca4180c00ece2df123cf962e5e6d7 (diff) |
CMake: Build test_programs automatically when running test
Since we require CMake version at least 3.7, we can use fixtures
to ensure that the unittests have been built before running
suite_unittests.
This only applies to running the tests via ctest (including
'[ninja|make] test'), not when running pytest directly.
Fix #17191
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 950f669cd6..4384cbb564 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3937,6 +3937,14 @@ set(_test_group_list set(TEST_EXTRA_ARGS "" CACHE STRING "Extra arguments to pass to test/test.py") separate_arguments(TEST_EXTRA_ARGS) +add_test(build_unittests + "${CMAKE_COMMAND}" + --build "${CMAKE_BINARY_DIR}" + --config "${CONFIG}" + --target test-programs +) +set_tests_properties(build_unittests PROPERTIES FIXTURES_SETUP unittests) + foreach(_group_name ${_test_group_list}) add_test( NAME ${_group_name} @@ -3950,6 +3958,8 @@ foreach(_group_name ${_test_group_list}) set_tests_properties(${_group_name} PROPERTIES TIMEOUT 600) endforeach() +set_tests_properties(suite_unittests PROPERTIES FIXTURES_REQUIRED unittests) + # Make it possible to run pytest without passing the full path as argument. if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" pytest_ini) |