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:
authorSybren A. Stüvel <sybren@blender.org>2019-11-28 19:37:27 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-11-28 19:41:32 +0300
commitf445f72ecadf21857a36b52b187620df158ef698 (patch)
tree728fdbc5a1fa22de2c7b115c461ff2663a949c40 /build_files
parenta8d29ad6e0628e315a1cb741b6136ad8823422dd (diff)
Tests: Blendfile-loading test class
This new test class minimally sets up Blender so that it can load blend files and construct a depsgraph without crashing. Note that it hasn't been tested on very complex blend files, so it may still crash when the loaded blend file references/requires uninitialised data structures. The test will certainly crash with Blend files created with Blender older than 2.80, as the versioning code requires space types to be registered. This is normally done by initialising the window manager, which is not done in this test. The WM requires Python to run, which in turn requires that Blender finds the release directory in the same directory that contains the running executable, which is not the case for GTest tests (they are written to `bin/tests/executablename`. Reviewed By: sergey, mont29 Differential Revision: https://developer.blender.org/D6246
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/Modules/GTestTesting.cmake36
1 files changed, 27 insertions, 9 deletions
diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake
index a93e829e6b0..2a05b92ba3f 100644
--- a/build_files/cmake/Modules/GTestTesting.cmake
+++ b/build_files/cmake/Modules/GTestTesting.cmake
@@ -12,9 +12,14 @@
#
#=============================================================================
-macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
+macro(BLENDER_SRC_GTEST_EX)
if(WITH_GTESTS)
- set(TARGET_NAME ${NAME}_test)
+ set(options SKIP_ADD_TEST)
+ set(oneValueArgs NAME)
+ set(multiValueArgs SRC EXTRA_LIBS COMMAND_ARGS)
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+
+ set(TARGET_NAME ${ARG_NAME}_test)
get_property(_current_include_directories
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
@@ -30,11 +35,11 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
)
unset(_current_include_directories)
- add_executable(${TARGET_NAME} ${SRC})
+ add_executable(${TARGET_NAME} ${ARG_SRC})
target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
target_link_libraries(${TARGET_NAME}
- ${EXTRA_LIBS}
+ ${ARG_EXTRA_LIBS}
${PLATFORM_LINKLIBS}
bf_testing_main
bf_intern_eigen
@@ -60,8 +65,11 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}")
- if(${DO_ADD_TEST})
- add_test(NAME ${TARGET_NAME} COMMAND ${TESTS_OUTPUT_DIR}/${TARGET_NAME} WORKING_DIRECTORY ${TEST_INSTALL_DIR})
+ if(NOT ARG_SKIP_ADD_TEST)
+ add_test(
+ NAME ${TARGET_NAME}
+ COMMAND ${TESTS_OUTPUT_DIR}/${TARGET_NAME} ${ARG_COMMAND_ARGS}
+ WORKING_DIRECTORY ${TEST_INSTALL_DIR})
# Don't fail tests on leaks since these often happen in external libraries
# that we can't fix.
@@ -74,13 +82,23 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
endmacro()
macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
- BLENDER_SRC_GTEST_EX("${NAME}" "${SRC}" "${EXTRA_LIBS}" "TRUE")
+ BLENDER_SRC_GTEST_EX(
+ NAME "${NAME}"
+ SRC "${SRC}"
+ EXTRA_LIBS "${EXTRA_LIBS}")
endmacro()
macro(BLENDER_TEST NAME EXTRA_LIBS)
- BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "TRUE")
+ BLENDER_SRC_GTEST_EX(
+ NAME "${NAME}"
+ SRC "${NAME}_test.cc"
+ EXTRA_LIBS "${EXTRA_LIBS}")
endmacro()
macro(BLENDER_TEST_PERFORMANCE NAME EXTRA_LIBS)
- BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "FALSE")
+ BLENDER_SRC_GTEST_EX(
+ NAME "${NAME}"
+ SRC "${NAME}_test.cc"
+ EXTRA_LIBS "${EXTRA_LIBS}"
+ SKIP_ADD_TEST)
endmacro()