[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29750] branches/soc-2010-leifandersen: 1.

Leif Andersen leif.a.andersen at gmail.com
Mon Jun 28 01:15:25 CEST 2010


Revision: 29750
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29750
Author:   leifandersen
Date:     2010-06-28 01:15:24 +0200 (Mon, 28 Jun 2010)

Log Message:
-----------
1.  Implemented render all operator, currently as 'funky' as render operator.  Select any file in the render tests folder to run them all.  (See last commit for setup).

Also, I relized I may have been unclear in my last commit, the render folder is of this structure:

render/ - the location where all of the renders go
render/render/ - the known 'good' renders
render/anim/ - A future location for animations
render/output/ - the location where the files from the last run are dumped.  (Currently, you're expected to remove them manually).

Also, it seems to only run all the tests if they all pass. (ie, if any fails, it abborts)

2.  Added a second blend file for testing render all test operator.  (This time it was from the actual render .blend file folder from the unit tests, so it's much more appropriate).

3.  Updated the piltest.py tester, so that it is a tad bit more leniant (and won't constantly spit out false positives).  Not much, but it's a start.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/release/scripts/op/tests_render.py
    branches/soc-2010-leifandersen/tests/piltest.py

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/render/arealight.blend
    branches/soc-2010-leifandersen/tests/render/render/arealight.blend.png

Modified: branches/soc-2010-leifandersen/release/scripts/op/tests_render.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/op/tests_render.py	2010-06-27 22:00:04 UTC (rev 29749)
+++ branches/soc-2010-leifandersen/release/scripts/op/tests_render.py	2010-06-27 23:15:24 UTC (rev 29750)
@@ -4,15 +4,17 @@
 from bpy.props import *
 
 BLENDER_BIN = sys.argv[0]
+PYTHON_BIN = "python"
+PILTEST_PY = "piltest.py"
 
 # Probably will be rewritten in C
 def compare_image(image1, image2):
-    command = "python piltest.py " + image1 + " " + image2
+    command = PYTHON_BIN + " " + PILTEST_PY + " " + image1 + " " + image2
     print(os.system(command))
 
 def render(path):
     (directory, filename) = os.path.split(path)
-    command = BLENDER_BIN + " -b " + path + " -o " + directory + os.path.sep + "output" + os.path.sep + filename + "_#### -F PNG -x 1 -f 1"
+    command = BLENDER_BIN + " -b " + path + " -o " + os.path.join(directory, "output", (filename + "_####")) + " -F PNG -x 1 -f 1"
     os.system(command)
     return (directory + os.path.sep + "output" + os.path.sep + filename + "_0001.png")
 
@@ -36,7 +38,7 @@
 
     def execute(self, context):
         (directory, filename) = os.path.split(self.properties.filepath)
-        image1 = directory + os.path.sep + "render" + os.path.sep + filename + ".png"
+        image1 = os.path.join(directory,"render",(filename + ".png"))
         image2 = render(self.properties.filepath)
         compare_image(image1, image2)
         return {'FINISHED'}
@@ -52,17 +54,30 @@
     bl_idname = "TESTS_OT_render_all"
     bl_label = "All Render Tests"
 
+    filename = StringProperty(name="File Name", description="File name used", maxlen= 1024, default= "")
+    filepath = StringProperty(name="File Path", description="Filepath used", maxlen= 1024, default= "")
+    directory = StringProperty(name="File Directory", description="File Directory used", maxlen= 1024, default= "")
+
     def poll(self, context):
         return True
 
     def execute(self, context):
+        (directory, filename) = os.path.split(self.properties.filepath)
+        for file in os.listdir(directory):
+            if file != 'output' and file != 'render' and file != 'anim':
+                bpy.ops.tests.render(filepath=self.properties.filepath)
         return {'FINISHED'}
 
+    def invoke(self, context,event):
+        wm = context.manager
+        wm.add_fileselect(self)
+        return {'RUNNING_MODAL'}
+
 classes = [
     TESTS_OT_render,
     TESTS_OT_render_all,
 ]
-
+    
 def register():
     for i in classes:
         bpy.types.register(i)

Modified: branches/soc-2010-leifandersen/tests/piltest.py
===================================================================
--- branches/soc-2010-leifandersen/tests/piltest.py	2010-06-27 22:00:04 UTC (rev 29749)
+++ branches/soc-2010-leifandersen/tests/piltest.py	2010-06-27 23:15:24 UTC (rev 29750)
@@ -26,11 +26,14 @@
                 im2_green+=im2.getpixel((i,j))[1]
                 im2_blue+=im2.getpixel((i,j))[2]
 
-        self.assertEquals(im1_red, im2_red)
-        self.assertEquals(im1_green, im2_green)
-        self.assertEquals(im1_blue, im2_blue)
+        im_red = abs(im1_red-im2_red)
+        im_green = abs(im1_green-im2_green)
+        im_blue = abs(im1_blue-im2_blue)
 
+        if im_red > 100 or im_green > 100 or im_blue > 100:
+            self.fail("Images are too different")
 
+
 def suite():
     return unittest.TestSuite([
 unittest.TestLoader().loadTestsFromTestCase(TestImage),

Added: branches/soc-2010-leifandersen/tests/render/arealight.blend
===================================================================
(Binary files differ)


Property changes on: branches/soc-2010-leifandersen/tests/render/arealight.blend
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/soc-2010-leifandersen/tests/render/render/arealight.blend.png
===================================================================
(Binary files differ)


Property changes on: branches/soc-2010-leifandersen/tests/render/render/arealight.blend.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream





More information about the Bf-blender-cvs mailing list