Build: Allow UI tests to run locally on all platforms
This commit allows the `WITH_UI_TESTS` CMake option to be used on all platforms, not only Linux. The existing functionality to use the Weston compositor was moved into the `WITH_UI_TESTS_HEADLESS` option. When these tests are run with only `WITH_UI_TESTS`, a visible instance of Blender is opened up for testing. Pull Request: https://projects.blender.org/blender/blender/pulls/135889
This commit is contained in:
@@ -848,8 +848,12 @@ Enable GPU drawing related unit testing (draw manager)"
|
||||
)
|
||||
option(WITH_GPU_COMPOSITOR_TESTS "Enable regression testing for GPU compositor" OFF)
|
||||
option(WITH_GPU_MESH_PAINT_TESTS "Enable visual render-based regression testing for mesh painting" OFF)
|
||||
option(WITH_UI_TESTS "\
|
||||
Enable user-interface tests (Experimental)"
|
||||
OFF
|
||||
)
|
||||
if(UNIX AND NOT (APPLE OR HAIKU))
|
||||
option(WITH_UI_TESTS "\
|
||||
option(WITH_UI_TESTS_HEADLESS "\
|
||||
Enable user-interface tests using a headless display server. \
|
||||
Currently this depends on WITH_GHOST_WAYLAND and the weston compositor \
|
||||
(Experimental)"
|
||||
@@ -862,8 +866,7 @@ packaged properly. For example that we don't link to any unexpected system libra
|
||||
OFF
|
||||
)
|
||||
else()
|
||||
# TODO: support running GUI tests on other platforms.
|
||||
set(WITH_UI_TESTS OFF)
|
||||
set(WITH_UI_TESTS_HEADLESS OFF)
|
||||
# TODO: We should probaby add more sanity checks for Windows and Mac as well
|
||||
set(WITH_LINUX_OFFICIAL_RELEASE_TESTS OFF)
|
||||
endif()
|
||||
@@ -1348,8 +1351,8 @@ endif()
|
||||
set_and_warn_incompatible(WITH_HEADLESS WITH_XR_OPENXR OFF)
|
||||
set_and_warn_incompatible(WITH_GHOST_SDL WITH_XR_OPENXR OFF)
|
||||
|
||||
if(WITH_UI_TESTS)
|
||||
set_and_warn_dependency(WITH_GHOST_WAYLAND WITH_UI_TESTS OFF)
|
||||
if(WITH_UI_TESTS_HEADLESS)
|
||||
set_and_warn_dependency(WITH_GHOST_WAYLAND WITH_UI_TESTS_HEADLESS OFF)
|
||||
endif()
|
||||
|
||||
if(WITH_BUILDINFO)
|
||||
|
||||
@@ -63,56 +63,74 @@ function(add_blender_test_io testname)
|
||||
endfunction()
|
||||
|
||||
if(WITH_UI_TESTS)
|
||||
set(_blender_headless_env_vars "BLENDER_BIN=${TEST_BLENDER_EXE}")
|
||||
if(WITH_UI_TESTS_HEADLESS)
|
||||
set(_blender_headless_env_vars "BLENDER_BIN=${TEST_BLENDER_EXE}")
|
||||
|
||||
# Currently only WAYLAND is supported, support for others may be added later.
|
||||
# In this case none of the WESTON environment variables will be used.
|
||||
if(WITH_GHOST_WAYLAND)
|
||||
set(_weston_bin_in_libdir OFF)
|
||||
if(DEFINED LIBDIR)
|
||||
set(_weston_bin_default "${LIBDIR}/wayland_weston/bin/weston")
|
||||
else()
|
||||
set(_weston_bin_default "weston")
|
||||
endif()
|
||||
set(WESTON_BIN "${_weston_bin_default}" CACHE STRING "\
|
||||
The location of weston, leave blank for the default location."
|
||||
)
|
||||
mark_as_advanced(WESTON_BIN)
|
||||
if((DEFINED LIBDIR) AND ("${WESTON_BIN}" STREQUAL "${_weston_bin_default}"))
|
||||
set(_weston_bin_in_libdir ON)
|
||||
endif()
|
||||
|
||||
list(APPEND _blender_headless_env_vars
|
||||
"WESTON_BIN=${WESTON_BIN}"
|
||||
)
|
||||
|
||||
if(_weston_bin_in_libdir)
|
||||
list(APPEND _blender_headless_env_vars
|
||||
"WAYLAND_ROOT_DIR=${LIBDIR}/wayland"
|
||||
"WESTON_ROOT_DIR=${LIBDIR}/wayland_weston"
|
||||
# Currently only WAYLAND is supported, support for others may be added later.
|
||||
# In this case none of the WESTON environment variables will be used.
|
||||
if(WITH_GHOST_WAYLAND)
|
||||
set(_weston_bin_in_libdir OFF)
|
||||
if(DEFINED LIBDIR)
|
||||
set(_weston_bin_default "${LIBDIR}/wayland_weston/bin/weston")
|
||||
else()
|
||||
set(_weston_bin_default "weston")
|
||||
endif()
|
||||
set(WESTON_BIN "${_weston_bin_default}" CACHE STRING "\
|
||||
The location of weston, leave blank for the default location."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
mark_as_advanced(WESTON_BIN)
|
||||
if((DEFINED LIBDIR) AND ("${WESTON_BIN}" STREQUAL "${_weston_bin_default}"))
|
||||
set(_weston_bin_in_libdir ON)
|
||||
endif()
|
||||
|
||||
function(add_blender_test_headless testname)
|
||||
# Remove `--background` so headless execution uses a GUI
|
||||
# (within a headless graphical environment).
|
||||
set(EXE_PARAMS ${TEST_BLENDER_EXE_PARAMS})
|
||||
list(REMOVE_ITEM EXE_PARAMS --background)
|
||||
add_blender_test_impl(
|
||||
"${testname}"
|
||||
"${_blender_headless_env_vars}"
|
||||
"${TEST_PYTHON_EXE}"
|
||||
"${CMAKE_SOURCE_DIR}/tests/utils/blender_headless.py"
|
||||
# NOTE: attempting to maximize the window causes problems with a headless `weston`,
|
||||
# while this could be investigated, use windowed mode instead.
|
||||
# Use a window size that balances software GPU rendering with enough room to use the UI.
|
||||
--factory-startup
|
||||
-p 0 0 800 600
|
||||
"${EXE_PARAMS}"
|
||||
"${ARGN}"
|
||||
)
|
||||
endfunction()
|
||||
list(APPEND _blender_headless_env_vars
|
||||
"WESTON_BIN=${WESTON_BIN}"
|
||||
)
|
||||
|
||||
if(_weston_bin_in_libdir)
|
||||
list(APPEND _blender_headless_env_vars
|
||||
"WAYLAND_ROOT_DIR=${LIBDIR}/wayland"
|
||||
"WESTON_ROOT_DIR=${LIBDIR}/wayland_weston"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(add_blender_test_ui testname)
|
||||
# Remove `--background` so headless execution uses a GUI
|
||||
# (within a headless graphical environment).
|
||||
set(EXE_PARAMS ${TEST_BLENDER_EXE_PARAMS})
|
||||
list(REMOVE_ITEM EXE_PARAMS --background)
|
||||
add_blender_test_impl(
|
||||
"${testname}"
|
||||
"${_blender_headless_env_vars}"
|
||||
"${TEST_PYTHON_EXE}"
|
||||
"${CMAKE_SOURCE_DIR}/tests/utils/blender_headless.py"
|
||||
# NOTE: attempting to maximize the window causes problems with a headless `weston`,
|
||||
# while this could be investigated, use windowed mode instead.
|
||||
# Use a window size that balances software GPU rendering with enough room to use the UI.
|
||||
--factory-startup
|
||||
-p 0 0 800 600
|
||||
"${EXE_PARAMS}"
|
||||
"${ARGN}"
|
||||
)
|
||||
endfunction()
|
||||
else()
|
||||
function(add_blender_test_ui testname)
|
||||
# Remove `--background`
|
||||
set(EXE_PARAMS ${TEST_BLENDER_EXE_PARAMS})
|
||||
list(REMOVE_ITEM EXE_PARAMS --background)
|
||||
|
||||
add_blender_test_impl(
|
||||
"${testname}"
|
||||
""
|
||||
"${TEST_BLENDER_EXE}"
|
||||
--factory-startup
|
||||
-p 0 0 800 600
|
||||
${EXE_PARAMS}
|
||||
${ARGN}
|
||||
)
|
||||
endfunction()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Run Python script outside Blender.
|
||||
@@ -1243,7 +1261,7 @@ if(WITH_UI_TESTS)
|
||||
test_undo.view3d_texture_paint_simple
|
||||
)
|
||||
foreach(ui_test ${_undo_tests})
|
||||
add_blender_test_headless(
|
||||
add_blender_test_ui(
|
||||
"ui_${ui_test}"
|
||||
--enable-event-simulate
|
||||
--python "${CMAKE_CURRENT_LIST_DIR}/ui_simulate/run_blender_setup.py"
|
||||
|
||||
Reference in New Issue
Block a user