diff options
Diffstat (limited to 'tests/python/CMakeLists.txt')
-rw-r--r-- | tests/python/CMakeLists.txt | 124 |
1 files changed, 47 insertions, 77 deletions
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index ceed2ca4d09..e03d8c065e7 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -513,30 +513,34 @@ add_test( ) endif() +# Run Python script outside Blender. +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} + ) + else() + add_test( + NAME ${testname} + COMMAND ${testscript} ${ARGN} + ) + endif() +endfunction() + if(WITH_CYCLES) if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/cycles/ctests/shader") macro(add_cycles_render_test subject) - if(MSVC) - add_test( - NAME cycles_${subject}_test - COMMAND - "$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>" - ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py - -blender "$<TARGET_FILE:blender>" - -testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}" - -idiff "${OPENIMAGEIO_IDIFF}" - -outdir "${TEST_OUT_DIR}/cycles" - ) - else() - add_test( - NAME cycles_${subject}_test - COMMAND ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py - -blender "$<TARGET_FILE:blender>" - -testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}" - -idiff "${OPENIMAGEIO_IDIFF}" - -outdir "${TEST_OUT_DIR}/cycles" - ) - endif() + add_python_test( + cycles_${subject}_test + ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py + -blender "$<TARGET_FILE:blender>" + -testdir "${TEST_SRC_DIR}/cycles/ctests/${subject}" + -idiff "${OPENIMAGEIO_IDIFF}" + -outdir "${TEST_OUT_DIR}/cycles" + ) endmacro() if(WITH_OPENGL_RENDER_TESTS) add_cycles_render_test(opengl) @@ -564,44 +568,23 @@ endif() if(WITH_OPENGL_DRAW_TESTS) if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/opengl") - macro(add_opengl_draw_test subject) - if(MSVC) - add_test( - NAME opengl_draw_${subject}_test - COMMAND - "$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>" + # Use all test folders + file(GLOB children RELATIVE ${TEST_SRC_DIR} ${TEST_SRC_DIR}/*) + foreach(child ${children}) + if(IS_DIRECTORY ${TEST_SRC_DIR}/${child}) + file(GLOB blends ${TEST_SRC_DIR}/${child}/*.blend) + if(blends) + add_python_test( + opengl_draw_${child}_test ${CMAKE_CURRENT_LIST_DIR}/opengl_draw_tests.py - -blender "$<TARGET_FILE:blender>" - -testdir "${TEST_SRC_DIR}/${subject}" - -idiff "${OPENIMAGEIO_IDIFF}" - -outdir "${TEST_OUT_DIR}/opengl_draw" - ) - else() - add_test( - NAME opengl_draw_${subject}_test - COMMAND ${CMAKE_CURRENT_LIST_DIR}/opengl_draw_tests.py - -blender "$<TARGET_FILE:blender>" - -testdir "${TEST_SRC_DIR}/${subject}" - -idiff "${OPENIMAGEIO_IDIFF}" - -outdir "${TEST_OUT_DIR}/opengl_draw" - ) - endif() - endmacro() - - function(add_opengl_draw_tests) - # Use all test folders - file(GLOB children RELATIVE ${TEST_SRC_DIR} ${TEST_SRC_DIR}/*) - foreach(child ${children}) - if(IS_DIRECTORY ${TEST_SRC_DIR}/${child}) - file(GLOB blends ${TEST_SRC_DIR}/${child}/*.blend) - if(blends) - add_opengl_draw_test(${child}) - endif() + -blender "$<TARGET_FILE:blender>" + -testdir "${TEST_SRC_DIR}/${child}" + -idiff "${OPENIMAGEIO_IDIFF}" + -outdir "${TEST_OUT_DIR}/opengl_draw" + ) endif() - endforeach() - endfunction() - - add_opengl_draw_tests() + endif() + endforeach() else() MESSAGE(STATUS "Disabling OpenGL tests because tests folder does not exist") endif() @@ -616,26 +599,13 @@ if(WITH_ALEMBIC) get_filename_component(real_include_dir ${ALEMBIC_INCLUDE_DIR} REALPATH) get_filename_component(ALEMBIC_ROOT_DIR ${real_include_dir} DIRECTORY) - if(MSVC) - # FIXME, de-duplicate. - add_test( - NAME alembic_tests - COMMAND - "$<TARGET_FILE_DIR:blender>/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python$<$<CONFIG:Debug>:_d>" - ${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py - --blender "$<TARGET_FILE:blender>" - --testdir "${TEST_SRC_DIR}/alembic" - --alembic-root "${ALEMBIC_ROOT_DIR}" - ) - else() - add_test( - NAME alembic_tests - COMMAND ${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py - --blender "$<TARGET_FILE:blender>" - --testdir "${TEST_SRC_DIR}/alembic" - --alembic-root "${ALEMBIC_ROOT_DIR}" - ) - endif() + add_python_test( + alembic_tests + ${CMAKE_CURRENT_LIST_DIR}/alembic_tests.py + --blender "$<TARGET_FILE:blender>" + --testdir "${TEST_SRC_DIR}/alembic" + --alembic-root "${ALEMBIC_ROOT_DIR}" + ) add_test( NAME script_alembic_import |