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
path: root/tests
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-07 15:03:39 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-07 19:09:41 +0300
commit2028302f4433910dc0841c4033b951275fa3f678 (patch)
tree3420a3d0aeab0cf26ad210dc19fc5cb825dfbb21 /tests
parent708e81bdfab1a7db4902c6512f009d9c4043428c (diff)
Tests: run tests from install path
Blender can only be run correctly from the install path since it requires Python scripts, dynamic libraries and other files to be present. By default the install path is the same as the build path, so it works anyway. But on the buildbot it isn't. There was a workaround but it failed on Windows and macOS. Now tests run from the install path. Detecting that path for ctest is more complicated than I would like, but I couldn't find a better solution. Ref T69541.
Diffstat (limited to 'tests')
-rw-r--r--tests/python/CMakeLists.txt51
1 files changed, 32 insertions, 19 deletions
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index 2125694701c..28029430673 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -32,24 +32,39 @@ file(MAKE_DIRECTORY ${TEST_OUT_DIR}/io_tests)
#~ message(FATAL_ERROR "CMake test directory not found!")
#~ endif()
-# all calls to blender use this
-# --env-system-scripts allows to run without the install target, but does
-# not work for all configurations.
-if(WITH_CYCLES OR (APPLE AND (${CMAKE_GENERATOR} MATCHES "Xcode")))
- set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup)
+# Blender arguments for tests.
+set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup)
+
+# Always run tests from install path, so all required scripts and libraries
+# are available and we are testing the actual installation layout.
+#
+# Getting the install path of the executable is somewhat involved, as there are
+# no direct CMake generator expressions to get the install paths of executables.
+if(GENERATOR_IS_MULTI_CONFIG)
+ string(REPLACE "\${BUILD_TYPE}" "$<CONFIG>" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
+else()
+ string(REPLACE "\${BUILD_TYPE}" "" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
+endif()
+
+if(MSVC)
+ set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender.exe)
+ set(TEST_PYTHON_EXE "${TEST_INSTALL_DIR}/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>")
+elseif(APPLE)
+ set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/Blender.app/Contents/MacOS/Blender)
+ set(TEST_PYTHON_EXE)
else()
- set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --env-system-scripts ${CMAKE_SOURCE_DIR}/release/scripts)
+ set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender)
+ set(TEST_PYTHON_EXE)
endif()
-# for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no
-# set(TEST_BLENDER_EXE_BARE ${TEST_BLENDER_EXE})
-# set(TEST_BLENDER_EXE ${TEST_BLENDER_EXE} ${TEST_BLENDER_EXE_PARAMS} )
+# For testing with Valgrind
+# set(TEST_BLENDER_EXE valgrind --track-origins=yes --error-limit=no ${TEST_BLENDER_EXE})
# Run Blender command with parameters.
function(add_blender_test testname)
add_test(
NAME ${testname}
- COMMAND "$<TARGET_FILE:blender>" ${TEST_BLENDER_EXE_PARAMS} ${ARGN}
+ COMMAND "${TEST_BLENDER_EXE}" ${TEST_BLENDER_EXE_PARAMS} ${ARGN}
)
# Don't fail tests on leaks since these often happen in external libraries
@@ -62,9 +77,7 @@ function(add_python_test testname testscript)
if(MSVC)
add_test(
NAME ${testname}
- COMMAND
- "$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>"
- ${testscript} ${ARGN}
+ COMMAND ${TEST_PYTHON_EXE} ${testscript} ${ARGN}
)
else()
add_test(
@@ -528,7 +541,7 @@ if(WITH_CYCLES OR WITH_OPENGL_RENDER_TESTS)
add_python_test(
cycles_${render_test}
${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
- -blender "$<TARGET_FILE:blender>"
+ -blender "${TEST_BLENDER_EXE}"
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-idiff "${OPENIMAGEIO_IDIFF}"
-outdir "${TEST_OUT_DIR}/cycles"
@@ -541,7 +554,7 @@ if(WITH_CYCLES OR WITH_OPENGL_RENDER_TESTS)
add_python_test(
eevee_${render_test}_test
${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
- -blender "$<TARGET_FILE:blender>"
+ -blender "${TEST_BLENDER_EXE}"
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-idiff "${OPENIMAGEIO_IDIFF}"
-outdir "${TEST_OUT_DIR}/eevee"
@@ -552,7 +565,7 @@ if(WITH_CYCLES OR WITH_OPENGL_RENDER_TESTS)
add_python_test(
workbench_${render_test}_test
${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
- -blender "$<TARGET_FILE:blender>"
+ -blender "${TEST_BLENDER_EXE}"
-testdir "${TEST_SRC_DIR}/render/${render_test}"
-idiff "${OPENIMAGEIO_IDIFF}"
-outdir "${TEST_OUT_DIR}/workbench"
@@ -579,7 +592,7 @@ if(WITH_OPENGL_DRAW_TESTS)
add_python_test(
opengl_draw_${child}
${CMAKE_CURRENT_LIST_DIR}/opengl_draw_tests.py
- -blender "$<TARGET_FILE:blender>"
+ -blender "${TEST_BLENDER_EXE}"
-testdir "${child_path}"
-idiff "${OPENIMAGEIO_IDIFF}"
-outdir "${TEST_OUT_DIR}/opengl_draw"
@@ -602,7 +615,7 @@ if(WITH_ALEMBIC)
add_python_test(
alembic_tests
${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py
- --blender "$<TARGET_FILE:blender>"
+ --blender "${TEST_BLENDER_EXE}"
--testdir "${TEST_SRC_DIR}/alembic"
--alembic-root "${ALEMBIC_ROOT_DIR}"
)
@@ -619,7 +632,7 @@ if(WITH_CODEC_FFMPEG)
add_python_test(
ffmpeg
${CMAKE_CURRENT_LIST_DIR}/ffmpeg_tests.py
- --blender "$<TARGET_FILE:blender>"
+ --blender "${TEST_BLENDER_EXE}"
--testdir "${TEST_SRC_DIR}/ffmpeg"
)
endif()