Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht>2020-09-15 12:16:35 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-09-17 13:29:19 +0300
commit532ac1163ceea857df0f3f144de0dde837712bbe (patch)
treeb07605683f3a3bb745f76043cd81b6db888c5f31 /build_files/cmake/macros.cmake
parentf9fcb25d521d11b425e1071a95ed342d9ddbef97 (diff)
Tests: bundle tests for some modules in their own executables
The ffmpeg, guardedalloc and blenlib are quite isolated and putting them in their own executable separate from blender_test is faster for development than linking the entire blender_tests executable. For Cycles, this also bundles all the unit tests into one executable. Ref T79958 Differential Revision: https://developer.blender.org/D8714
Diffstat (limited to 'build_files/cmake/macros.cmake')
-rw-r--r--build_files/cmake/macros.cmake47
1 files changed, 44 insertions, 3 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 268daa4aae3..1e3863ac567 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -375,9 +375,8 @@ function(blender_add_lib
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
endfunction()
-# blender_add_test_lib() is used to define a test library. It is intended to be
-# called in tandem with blender_add_lib(). The test library will be linked into
-# the bf_gtest_runner_test executable (see tests/gtests/CMakeLists.txt).
+# 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
name
sources
@@ -411,6 +410,48 @@ function(blender_add_test_lib
set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name})
endfunction()
+
+# Add tests for a Blender library, to be called in tandem with blender_add_lib().
+# Test will be compiled into a ${name}_test executable.
+#
+# To be used for smaller isolated libraries, that do not have many dependencies.
+# For libraries that do drag in many other Blender libraries and would create a
+# very large executable, blender_add_test_lib() should be used instead.
+function(blender_add_test_executable
+ name
+ sources
+ includes
+ includes_sys
+ library_deps
+ )
+
+ add_cc_flags_custom_test(${name} PARENT_SCOPE)
+
+ ## Otherwise external projects will produce warnings that we cannot fix.
+ remove_strict_flags()
+
+ include_directories(${includes})
+ include_directories(${includes_sys})
+ setup_libdirs()
+
+ BLENDER_SRC_GTEST_EX(
+ NAME ${name}
+ SRC "${sources}"
+ EXTRA_LIBS "${library_deps}"
+ 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}"
+ )
+endfunction()
+
# Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build.
function(setup_heavy_lib_pool)
if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)