Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 28 Sep 2018 13:03:03 +0000 (15:03 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 28 Sep 2018 13:03:03 +0000 (15:03 +0200)
1  2 
tests/python/CMakeLists.txt
tests/python/modules/render_report.py

index d5ba68b9b93d53251d2907ec30338cd13b9d2a58,b5cc39ae37a9c1aee7e9ceba5f88df3f72497b34..9faedf93d620f7e58a32fd8b8664d0e601bb14e6
@@@ -531,9 -531,9 +531,9 @@@ function(add_python_test testname tests
        endif()
  endfunction()
  
 -if(WITH_CYCLES)
 -      if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
 -              macro(add_cycles_render_test subject)
 +if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
 +      macro(add_cycles_render_test subject)
 +              if(WITH_CYCLES)
                        add_python_test(
                                cycles_${subject}_test
                                ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
                                -idiff "${OPENIMAGEIO_IDIFF}"
                                -outdir "${TEST_OUT_DIR}/cycles"
                        )
 -              endmacro()
 -              if(WITH_OPENGL_RENDER_TESTS)
 -                      add_cycles_render_test(opengl)
                endif()
 -              add_cycles_render_test(bake)
 -              add_cycles_render_test(bsdf)
 -              add_cycles_render_test(denoise)
 -              add_cycles_render_test(displacement)
 -              add_cycles_render_test(hair)
 -              add_cycles_render_test(image_data_types)
 -              add_cycles_render_test(image_mapping)
 -              add_cycles_render_test(image_texture_limit)
 -              add_cycles_render_test(integrator)
 -              add_cycles_render_test(light)
 -              add_cycles_render_test(mesh)
 -              add_cycles_render_test(motion_blur)
 -              add_cycles_render_test(render_layer)
 -              add_cycles_render_test(reports)
 -              add_cycles_render_test(shader)
 -              add_cycles_render_test(shadow_catcher)
 -              add_cycles_render_test(sss)
 -              add_cycles_render_test(volume)
 -      else()
 -              MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist")
 -      endif()
 +
 +              if(WITH_OPENGL_RENDER_TESTS AND (NOT ${subject} MATCHES "bake"))
 +                      add_python_test(
 +                              eevee_${subject}_test
 +                              ${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
 +                              -blender "$<TARGET_FILE:blender>"
 +                              -testdir "${TEST_SRC_DIR}/render/ctests/${subject}"
 +                              -idiff "${OPENIMAGEIO_IDIFF}"
 +                              -outdir "${TEST_OUT_DIR}/eevee"
 +                      )
 +              endif()
 +      endmacro()
 +      add_cycles_render_test(bake)
 +      add_cycles_render_test(bsdf)
 +      add_cycles_render_test(denoise)
 +      add_cycles_render_test(displacement)
 +      add_cycles_render_test(hair)
 +      add_cycles_render_test(image_data_types)
 +      add_cycles_render_test(image_mapping)
 +      add_cycles_render_test(image_texture_limit)
 +      add_cycles_render_test(integrator)
 +      add_cycles_render_test(light)
 +      add_cycles_render_test(mesh)
 +      add_cycles_render_test(motion_blur)
 +      add_cycles_render_test(render_layer)
 +      add_cycles_render_test(reports)
 +      add_cycles_render_test(shader)
 +      add_cycles_render_test(shadow_catcher)
 +      add_cycles_render_test(sss)
 +      add_cycles_render_test(volume)
 +elseif(WITH_CYCLES)
 +      MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist")
  endif()
  
  if(WITH_OPENGL_DRAW_TESTS)
                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)
+                               file(GLOB_RECURSE blends "${TEST_SRC_DIR}/${child}/*.blend")
                                if(blends)
                                        add_python_test(
                                                opengl_draw_${child}_test
@@@ -638,6 -630,3 +638,6 @@@ if(WITH_CODEC_FFMPEG
  endif()
  
  add_subdirectory(collada)
 +
 +# TODO: disabled for now after collection unification
 +# add_subdirectory(view_layer)
index 1f0022f13b6a074c135bfab6218ef6fc086d064f,ebfc58997c08930f283cca22e218f75183816df4..8deed25e8543eda5e2d4cb9564b86c08c4a326b3
@@@ -51,10 -51,11 +51,11 @@@ def print_message(message, type=None, s
  
  
  def blend_list(dirpath):
-     for filename in os.listdir(dirpath):
-         if filename.lower().endswith(".blend"):
-             filepath = os.path.join(dirpath, filename)
-             yield filepath
+     for root, dirs, files in os.walk(dirpath):
+         for filename in files:
+             if filename.lower().endswith(".blend"):
+                 filepath = os.path.join(root, filename)
+                 yield filepath
  
  
  def test_get_name(filepath):
      return os.path.splitext(filename)[0]
  
  
 -def test_get_images(output_dir, filepath):
 +def test_get_images(output_dir, filepath, reference_dir):
      testname = test_get_name(filepath)
      dirpath = os.path.dirname(filepath)
  
 -    old_dirpath = os.path.join(dirpath, "reference_renders")
 +    old_dirpath = os.path.join(dirpath, reference_dir)
      old_img = os.path.join(old_dirpath, testname + ".png")
  
      ref_dirpath = os.path.join(output_dir, os.path.basename(dirpath), "ref")
@@@ -93,23 -94,18 +94,23 @@@ class Report
      __slots__ = (
          'title',
          'output_dir',
 +        'reference_dir',
          'idiff',
          'pixelated',
          'verbose',
          'update',
          'failed_tests',
 -        'passed_tests'
 +        'passed_tests',
 +        'compare_tests',
 +        'compare_engines'
      )
  
      def __init__(self, title, output_dir, idiff):
          self.title = title
          self.output_dir = output_dir
 +        self.reference_dir = 'reference_renders'
          self.idiff = idiff
 +        self.compare_engines = None
  
          self.pixelated = False
          self.verbose = os.environ.get("BLENDER_VERBOSE") is not None
  
          self.failed_tests = ""
          self.passed_tests = ""
 +        self.compare_tests = ""
  
          if not os.path.exists(output_dir):
              os.makedirs(output_dir)
      def set_pixelated(self, pixelated):
          self.pixelated = pixelated
  
 +    def set_reference_dir(self, reference_dir):
 +        self.reference_dir = reference_dir
 +
 +    def set_compare_engines(self, engine, other_engine):
 +        self.compare_engines = (engine, other_engine)
 +
      def run(self, dirpath, render_cb):
          # Run tests and output report.
          dirname = os.path.basename(dirpath)
          ok = self._run_all_tests(dirname, dirpath, render_cb)
 -        self._write_html(dirname)
 +        self._write_data(dirname)
 +        self._write_html()
 +        if self.compare_engines:
 +            self._write_html(comparison=True)
          return ok
  
 -    def _write_html(self, dirname):
 +    def _write_data(self, dirname):
          # Write intermediate data for single test.
          outdir = os.path.join(self.output_dir, dirname)
          if not os.path.exists(outdir):
          filepath = os.path.join(outdir, "passed.data")
          pathlib.Path(filepath).write_text(self.passed_tests)
  
 +        if self.compare_engines:
 +            filepath = os.path.join(outdir, "compare.data")
 +            pathlib.Path(filepath).write_text(self.compare_tests)
 +
 +    def _write_html(self, comparison=False):
          # Gather intermediate data for all tests.
 -        failed_data = sorted(glob.glob(os.path.join(self.output_dir, "*/failed.data")))
 -        passed_data = sorted(glob.glob(os.path.join(self.output_dir, "*/passed.data")))
 +        if comparison:
 +            failed_data = []
 +            passed_data = sorted(glob.glob(os.path.join(self.output_dir, "*/compare.data")))
 +        else:
 +            failed_data = sorted(glob.glob(os.path.join(self.output_dir, "*/failed.data")))
 +            passed_data = sorted(glob.glob(os.path.join(self.output_dir, "*/passed.data")))
  
          failed_tests = ""
          passed_tests = ""
          else:
              message = ""
  
 +        if comparison:
 +            title = "Render Test Compare"
 +            columns_html = "<tr><th>Name</th><th>%s</th><th>%s</th>" % self.compare_engines
 +        else:
 +            title = self.title
 +            columns_html = "<tr><th>Name</th><th>New</th><th>Reference</th><th>Diff</th>"
 +
          html = """
  <html>
  <head>
          <br/>
          <table class="table table-striped">
              <thead class="thead-default">
 -                <tr><th>Name</th><th>New</th><th>Reference</th><th>Diff</th>
 +                {columns_html}
              </thead>
              {tests_html}
          </table>
      </div>
  </body>
  </html>
 -            """ . format(title=self.title,
 +            """ . format(title=title,
                           message=message,
                           image_rendering=image_rendering,
 -                         tests_html=tests_html)
 +                         tests_html=tests_html,
 +                         columns_html=columns_html)
  
 -        filepath = os.path.join(self.output_dir, "report.html")
 +        filename = "report.html" if not comparison else "compare.html"
 +        filepath = os.path.join(self.output_dir, filename)
          pathlib.Path(filepath).write_text(html)
  
          print_message("Report saved to: " + pathlib.Path(filepath).as_uri())
          name = test_get_name(filepath)
          name = name.replace('_', ' ')
  
 -        old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath)
 +        old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath, self.reference_dir)
  
          status = error if error else ""
          tr_style = """ style="background-color: #f99;" """ if error else ""
          else:
              self.passed_tests += test_html
  
 +        if self.compare_engines:
 +            ref_url = os.path.join("..", self.compare_engines[1], new_url)
 +
 +            test_html = """
 +                <tr{tr_style}>
 +                    <td><b>{name}</b><br/>{testname}<br/>{status}</td>
 +                    <td><img src="{new_url}" onmouseover="this.src='{ref_url}';" onmouseout="this.src='{new_url}';" class="render"></td>
 +                    <td><img src="{ref_url}" onmouseover="this.src='{new_url}';" onmouseout="this.src='{ref_url}';" class="render"></td>
 +                </tr>""" . format(tr_style=tr_style,
 +                                  name=name,
 +                                  testname=testname,
 +                                  status=status,
 +                                  new_url=new_url,
 +                                  ref_url=ref_url)
 +
 +            self.compare_tests += test_html
 +
      def _diff_output(self, filepath, tmp_filepath):
 -        old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath)
 +        old_img, ref_img, new_img, diff_img = test_get_images(self.output_dir, filepath, self.reference_dir)
  
          # Create reference render directory.
          old_dirpath = os.path.dirname(old_img)