[Bf-blender-cvs] [fb3e138ceed] master: Tests: add Eevee reference images, and add workbench tests

Brecht Van Lommel noreply at git.blender.org
Mon May 6 20:16:02 CEST 2019


Commit: fb3e138ceedab82bc7c743c8cb4790fbadbb9986
Author: Brecht Van Lommel
Date:   Mon May 6 19:46:32 2019 +0200
Branches: master
https://developer.blender.org/rBfb3e138ceedab82bc7c743c8cb4790fbadbb9986

Tests: add Eevee reference images, and add workbench tests

Being able to compare Eevee reference images is useful for refactoring I'm
working on so might as well add them now, even if we can still improve them.

Workbench tests are just rendering the same files as Cycles and Eevee. This
doesn't really tests many workbench settings until we add tests specifically
for them, but does cover how it it handles the different object types.

===================================================================

M	tests/python/CMakeLists.txt
M	tests/python/cycles_render_tests.py
A	tests/python/workbench_render_tests.py

===================================================================

diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index 2d9fe8c4f37..28bdd48229e 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -528,14 +528,14 @@ function(add_python_test testname testscript)
   endif()
 endfunction()
 
-if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
+if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/shader")
   macro(add_cycles_render_test subject)
     if(WITH_CYCLES)
       add_python_test(
         cycles_${subject}
         ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
         -blender "$<TARGET_FILE:blender>"
-        -testdir "${TEST_SRC_DIR}/render/ctests/${subject}"
+        -testdir "${TEST_SRC_DIR}/render/${subject}"
         -idiff "${OPENIMAGEIO_IDIFF}"
         -outdir "${TEST_OUT_DIR}/cycles"
       )
@@ -546,10 +546,19 @@ if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
         eevee_${subject}_test
         ${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
         -blender "$<TARGET_FILE:blender>"
-        -testdir "${TEST_SRC_DIR}/render/ctests/${subject}"
+        -testdir "${TEST_SRC_DIR}/render/${subject}"
         -idiff "${OPENIMAGEIO_IDIFF}"
         -outdir "${TEST_OUT_DIR}/eevee"
       )
+
+      add_python_test(
+        workbench_${subject}_test
+        ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
+        -blender "$<TARGET_FILE:blender>"
+        -testdir "${TEST_SRC_DIR}/render/${subject}"
+        -idiff "${OPENIMAGEIO_IDIFF}"
+        -outdir "${TEST_OUT_DIR}/workbench"
+      )
     endif()
   endmacro()
   add_cycles_render_test(bake)
diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py
index 381c04d9b7f..36f5459c2f7 100755
--- a/tests/python/cycles_render_tests.py
+++ b/tests/python/cycles_render_tests.py
@@ -106,6 +106,7 @@ def main():
     from modules import render_report
     report = render_report.Report("Cycles Test Report", output_dir, idiff)
     report.set_pixelated(True)
+    report.set_reference_dir("cycles_renders")
     report.set_compare_engines('cycles', 'eevee')
     ok = report.run(test_dir, render_file)
 
diff --git a/tests/python/cycles_render_tests.py b/tests/python/workbench_render_tests.py
similarity index 62%
copy from tests/python/cycles_render_tests.py
copy to tests/python/workbench_render_tests.py
index 381c04d9b7f..5b759214140 100755
--- a/tests/python/cycles_render_tests.py
+++ b/tests/python/workbench_render_tests.py
@@ -9,6 +9,28 @@ import subprocess
 import sys
 
 
+def setup():
+    import bpy
+
+    scene = bpy.context.scene
+    scene.display.shading.color_type = 'TEXTURE'
+
+
+# When run from inside Blender, render and exit.
+try:
+    import bpy
+    inside_blender = True
+except ImportError:
+    inside_blender = False
+
+if inside_blender:
+    try:
+        setup()
+    except Exception as e:
+        print(e)
+        sys.exit(1)
+
+
 def render_file(filepath, output_filepath):
     dirname = os.path.dirname(filepath)
     basedir = os.path.dirname(dirname)
@@ -16,38 +38,19 @@ def render_file(filepath, output_filepath):
 
     frame_filepath = output_filepath + '0001.png'
 
-    common_args = [
+    command = [
+        BLENDER,
+        "--background",
         "-noaudio",
         "--factory-startup",
         "--enable-autoexec",
         filepath,
-        "-E", "CYCLES",
+        "-E", "BLENDER_WORKBENCH",
+        "-P",
+        os.path.realpath(__file__),
         "-o", output_filepath,
-        "-F", "PNG"]
-
-    # OSL and GPU examples
-    # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True"]
-    # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"]
-    custom_args = os.getenv('CYCLESTEST_ARGS')
-    custom_args = shlex.split(custom_args) if custom_args else []
-    common_args += custom_args
-
-    if subject == 'opengl':
-        command = [BLENDER, "--window-geometry", "0", "0", "1", "1"]
-        command += common_args
-        command += ['--python', os.path.join(basedir, "util", "render_opengl.py")]
-    elif subject == 'bake':
-        command = [BLENDER, "--background"]
-        command += common_args
-        command += ['--python', os.path.join(basedir, "util", "render_bake.py")]
-    elif subject == 'denoise_animation':
-        command = [BLENDER, "--background"]
-        command += common_args
-        command += ['--python', os.path.join(basedir, "util", "render_denoise.py")]
-    else:
-        command = [BLENDER, "--background"]
-        command += common_args
-        command += ["-f", "1"]
+        "-F", "PNG",
+        "-f", "1"]
 
     try:
         # Success
@@ -104,13 +107,14 @@ def main():
     output_dir = args.outdir[0]
 
     from modules import render_report
-    report = render_report.Report("Cycles Test Report", output_dir, idiff)
+    report = render_report.Report("Workbench Test Report", output_dir, idiff)
     report.set_pixelated(True)
-    report.set_compare_engines('cycles', 'eevee')
+    report.set_reference_dir("workbench_renders")
+    report.set_compare_engines('workbench', 'eevee')
     ok = report.run(test_dir, render_file)
 
     sys.exit(not ok)
 
 
-if __name__ == "__main__":
+if not inside_blender and __name__ == "__main__":
     main()



More information about the Bf-blender-cvs mailing list