diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-01-11 13:29:30 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-01-11 13:29:30 +0300 |
commit | 54f8a5dd737388d89332f3074eba01edc9efa8c1 (patch) | |
tree | 5ed34e5235a250625130aeab7bdc4cbc5647071c /build_files/cmake/macros.cmake | |
parent | 63cea2b793d0dd98b69cab156ba3be4dcf9f234a (diff) |
Tests: run suites instead of individual test cases
Group all tests of a test suite into a single test command invocation.
This reduces the number of invocations by `ctest` by an order of
magnitude.
Since rB56aa5b0d8c6b663, `bin/tests/blender_test` was run for every
individual test. Having over a 1000 tests made testing slower than
necessary. Individual tests can still be run if desired by invocation of
`bin/tests/blender_test --gtest_filter=suitename.testname`.
NOTE: For this commit to have an immediate effect, it may be necessary
to remove the `tests` and `Testing` directories and some CMake files
from your build directory and rebuild. Run `ctest -N` to see the list of
tests; there should be less than 200.
Reviewed By: sergey, LazyDodo, sebbas
Maniphest Tasks: T83222
Differential Revision: https://developer.blender.org/D9649
Diffstat (limited to 'build_files/cmake/macros.cmake')
-rw-r--r-- | build_files/cmake/macros.cmake | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 9febeaa6889..f4b36597611 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -388,6 +388,43 @@ function(blender_add_lib set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) endfunction() +function(blender_add_test_suite) + if (ARGC LESS 1) + message(FATAL_ERROR "No arguments supplied to blender_add_test_suite()") + endif() + + # Parse the arguments + set(oneValueArgs TARGET SUITE_NAME) + set(multiValueArgs SOURCES) + cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Figure out the release dir, as some tests need files from there. + GET_BLENDER_TEST_INSTALL_DIR(TEST_INSTALL_DIR) + if(APPLE) + set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION}) + else() + if(WIN32 OR WITH_INSTALL_PORTABLE) + set(_test_release_dir ${TEST_INSTALL_DIR}/${BLENDER_VERSION}) + else() + set(_test_release_dir ${TEST_INSTALL_DIR}/share/blender/${BLENDER_VERSION}) + endif() + endif() + + # Define a test case with our custom gtest_add_tests() command. + include(GTest) + gtest_add_tests( + TARGET ${ARGS_TARGET} + SOURCES "${ARGS_SOURCES}" + TEST_PREFIX ${ARGS_SUITE_NAME} + WORKING_DIRECTORY "${TEST_INSTALL_DIR}" + EXTRA_ARGS + --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests" + --test-release-dir "${_test_release_dir}" + ) + + unset(_test_release_dir) +endfunction() + # Add tests for a Blender library, to be called in tandem with blender_add_lib(). # The tests will be part of the blender_test executable (see tests/gtests/runner). function(blender_add_test_lib @@ -421,6 +458,12 @@ function(blender_add_test_lib blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name}) + + blender_add_test_suite( + TARGET blender_test + SUITE_NAME ${name} + SOURCES "${sources}" + ) endfunction() @@ -454,14 +497,10 @@ function(blender_add_test_executable SKIP_ADD_TEST ) - include(GTest) - set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT - ${CMAKE_SOURCE_DIR}/build_files/cmake/Modules/GTestAddTests.cmake - ) - - gtest_discover_tests(${name}_test - DISCOVERY_MODE PRE_TEST - WORKING_DIRECTORY "${TEST_INSTALL_DIR}" + blender_add_test_suite( + TARGET ${name}_test + SUITE_NAME ${name} + SOURCES "${sources}" ) endfunction() |