1 # SPDX-FileCopyrightText: 2014-2023 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # Always run tests from install path, so all required scripts and libraries
6 # are available and we are testing the actual installation layout.
8 # Getting the install path of the executable is somewhat involved, as there are
9 # no direct CMake generator expressions to get the install paths of executables.
10 set(TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX_WITH_CONFIG})
12 # Path to Blender and Python executables for all platforms.
14 set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender.exe)
16 set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/Blender.app/Contents/MacOS/Blender)
18 if(WITH_INSTALL_PORTABLE)
19 set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender)
21 set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/bin/blender)
25 # The installation directory's Python is the best one to use. However, it can only be there
26 # after the install step, # which means that Python will never be there on a fresh system.
27 # To suit different needs, the user can pass `-DTEST_PYTHON_EXE=/path/to/python` to CMake.
28 if(NOT TEST_PYTHON_EXE)
29 set(TEST_PYTHON_EXE ${PYTHON_EXECUTABLE})
31 message(STATUS "Tests: Using Python executable: ${TEST_PYTHON_EXE}")
33 elseif(NOT EXISTS ${TEST_PYTHON_EXE})
34 message(FATAL_ERROR "Tests: TEST_PYTHON_EXE ${TEST_PYTHON_EXE} does not exist")
38 # Include these arguments before all others, they must not interfere with Python execution.
39 set(TEST_PYTHON_EXE_EXTRA_ARGS "")
41 # Check if this a Blender managed Python installation, if so, don't add `*.pyc` files.
43 path_is_prefix(LIBDIR TEST_PYTHON_EXE _is_prefix)
45 # Keep the Python in Blender's SVN LIBDIR pristine, to avoid conflicts on updating.
46 set(TEST_PYTHON_EXE_EXTRA_ARGS "-B")
51 # For testing with Valgrind
52 # set(TEST_BLENDER_EXE valgrind --track-origins=yes --error-limit=no ${TEST_BLENDER_EXE})
54 # Standard Blender arguments for running tests.
55 # Specify exit code so that if a Python script error happens, the test fails.
56 set(TEST_BLENDER_EXE_PARAMS
57 --background --factory-startup --debug-memory --debug-exit-on-error --python-exit-code 1
61 if(WITH_BLENDER AND WITH_PYTHON AND NOT WITH_PYTHON_MODULE)
62 add_subdirectory(python)
65 # Blender as python module tests.
66 if(WITH_PYTHON_MODULE)
67 add_subdirectory(blender_as_python_module)
71 add_subdirectory(gtests)