[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30276] branches/soc-2010-leifandersen/ tests/render: Fixed many bugs, mainly with regard to mixing parameters ( which would be used to make the tests more powerful)

Leif Andersen leif.a.andersen at gmail.com
Tue Jul 13 18:53:02 CEST 2010


Revision: 30276
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30276
Author:   leifandersen
Date:     2010-07-13 18:53:01 +0200 (Tue, 13 Jul 2010)

Log Message:
-----------
Fixed many bugs, mainly with regard to mixing parameters (which would be used to make the tests more powerful)

Modified Paths:
--------------
    branches/soc-2010-leifandersen/tests/render/hashcodes.txt
    branches/soc-2010-leifandersen/tests/render/run.py

Modified: branches/soc-2010-leifandersen/tests/render/hashcodes.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/render/hashcodes.txt	2010-07-13 16:11:16 UTC (rev 30275)
+++ branches/soc-2010-leifandersen/tests/render/hashcodes.txt	2010-07-13 16:53:01 UTC (rev 30276)
@@ -27,4 +27,5 @@
 Image: teapot_envmap.blend 68155147
 Image: teapot_soft.blend 16755754
 Image: text-regression.blend 312492495
-Image: windows_tra_shadow.blend 13032008
\ No newline at end of file
+Image: windows_tra_shadow.blend 13032008
+Animation: glass.blend 232808186

Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py	2010-07-13 16:11:16 UTC (rev 30275)
+++ branches/soc-2010-leifandersen/tests/render/run.py	2010-07-13 16:53:01 UTC (rev 30276)
@@ -28,6 +28,7 @@
 HASHCODE_TEST = False
 HASHCODE_FILE = os.path.join(sys.path[0], 'hashcodes.txt')
 GET_HASHCODES = False
+OPTIONAL_CASES = []
 
 HELP = '''Help to come'''
 
@@ -253,27 +254,38 @@
 
     def setup_image(self, blend_path, good_path, test_path):
         ''''''
-        self.name = os.path.split(blend_path)[1]
-        for imagename in os.listdir(good_path):
-            if imagename.find('.png') != -1:
-                self.good_path_arr.append(os.path.join(good_path, imagename))
-        self.good_path_arr.sort()
-        self.mode = 'Image'
+        try:
+            self.name = os.path.split(blend_path)[1]
+            self.blend_path = blend_path
+            for imagename in os.listdir(good_path):
+                if imagename.find('.png') != -1:
+                    self.good_path_arr.append(os.path.join(good_path, imagename))
+            self.good_path_arr.sort()
+            self.mode = 'Image'
+            
+            i=1
+            for imagename in self.good_path_arr:
+                (imagepath, blendname) = os.path.split(imagename)
+                im = Image.open(self.good_path_arr[i-1])
+                self.good_animation.append(im)
+                self.test_path_arr.append(os.path.join(test_path, blendname))
+                # self.good_hash_arr.append(self.generate_hash_image(im)) TODO removed due to time contstraint
+                i+=1
         
-        i=1
-        for imagename in self.good_path_arr:
-            im = Image.open(self.good_path_arr[i-1])
-            self.good_animation.append(im)
-            self.test_path_arr.append(os.path.join(test_path, string.replace(self.name, '.blend', '_' + self.format_frame(i) + '.png')))
-            # self.good_hash_arr.append(self.generate_hash_image(im)) TODO removed due to time contstraint
-            i+=1
+            self.good_path = self.good_path_arr[0]
+            self.good_image = self.good_animation[0]
+            self.test_path = self.test_path_arr[0]
+        except IOError:
+            self.mode = 'Fail'
+            self.good_image = None
+            self.good_hash = -1
+            self.test_path = os.path.join(test_path, string.replace(self.name, '.blend', '_0001.png'))
+        except OSError:
+            self.mode = 'Fail'
+            self.good_image = None
+            self.good_hash = -1
+            self.test_path = os.path.join(test_path, string.replace(self.name, '.blend', '_0001.png'))
 
-        self.blend_path = blend_path
-        self.good_path = self.good_path_arr[0]
-        self.good_image = self.good_animation[0]
-        self.test_path = self.test_path_arr[0]
-#        self.good_hash = self.generate_hash(self.good_animation)
-
     def generate_hash(self, animation):
         hash = 0
         for image in animation:
@@ -307,8 +319,8 @@
             for imagename in self.test_path_arr:
                 im = Image.open(imagename)
                 self.test_animation.append(im)
-                # self.test_hash_arr.append(self.generate_hash_image(im)) TODO, removed due to time constraint
-            self.test_image = self.test_animation[0]
+            if len(self.test_animation) > 0:
+                self.test_image = self.test_animation[0]
             self.test_hash = self.generate_hash(self.test_animation)
         except IOError:
             self.mdoe = 'Fail'
@@ -453,8 +465,8 @@
                     cases.append(test_case)
             for (name, code) in animation_cases:
                 if name == blend_name:
+                    hash_code = code
                     blend_path = os.path.join(blend_file_folder, filename)
-                    hash_coe = code
                     test_path = os.path.join(output_folder, string.replace(filename, '.blend', ''))
                     test_case = AnimationTestCase()
                     test_case.setup_hash(blend_path, int(hash_code), test_path)
@@ -753,8 +765,7 @@
             argv_path = sys.argv[argv_i + 1]
             (argv_directory, argv_file) = os.path.split(argv_path)
             case = AnimationTestCase()
-            case.setup_image(argv_path, os.path.join(argv_directory, string.replace(argv_file, '.blend', '')), os.path.join(argv_directory, 'output', string.replace(argv_file, '.blend', '')))
-            cases.append(case)
+            OPTIONAL_CASES.append((case, argv_path, os.path.join(argv_directory, string.replace(argv_file, '.blend', '')), os.path.join(argv_directory, 'output', string.replace(argv_file, '.blend', ''))))
         if arg == '--with-animations':
             RUN_IMAGES_AND_ANIMATIONS = True
             RUN_IMAGES = False
@@ -763,8 +774,7 @@
             argv_path = sys.argv[argv_i + 1]
             (argv_directory, argv_file) = os.path.split(argv_path)
             case = ImageTestCase()
-            case.setup_image( argv_path, os.path.join(argv_directory, 'render', string.replace(argv_file, '.blend', '.png')), os.path.join(argv_directory, 'output', string.replace(argv_file, '.blend', '')))
-            cases.append(case)
+            OPTIONAL_CASES.append((case, argv_path, os.path.join(argv_directory, 'render', string.replace(argv_file, '.blend', '.png')), os.path.join(argv_directory, 'output', string.replace(argv_file, '.blend', ''))))
             HTML_OUTPUT =  argv_directory
         if arg == '-v' or arg == '-V' or arg == '--verbose':
             VERBOSE = True
@@ -791,17 +801,33 @@
         argv_i += 1
     
     # Get cases, unless told not to.
-    if RUN_IMAGES:
-        cases = get_image_cases(BLEND_FILE_FOLDER, GOOD_FOLDER, OUTPUT_FOLDER)
-        cases.sort(key=lambda case: case.name)
+    if RUN_IMAGES and HASHCODE_TEST == False and len(OPTIONAL_CASES) == 0:
+        cases += get_image_cases(BLEND_FILE_FOLDER, GOOD_FOLDER, OUTPUT_FOLDER)
 
-    if RUN_IMAGES_AND_ANIMATIONS:
-        cases = get_image_cases(BLEND_FILE_FOLDER, GOOD_FOLDER, OUTPUT_FOLDER)
+    if RUN_IMAGES_AND_ANIMATIONS and HASHCODE_TEST == False and len(OPTIONAL_CASES) == 0:
+        cases += get_image_cases(BLEND_FILE_FOLDER, GOOD_FOLDER, OUTPUT_FOLDER)
         cases += get_animation_cases(ANIM_BLEND_FILE_FOLDER, ANIM_GOOD_FOLDER, ANIM_OUTPUT_FOLDER)
-        cases.sort(key=lambda case: case.name)
 
-    if HASHCODE_TEST == True:
-        cases = get_hash_cases(BLEND_FILE_FOLDER, HASHCODE_FILE, OUTPUT_FOLDER)
+    if HASHCODE_TEST == True and len(OPTIONAL_CASES) == 0:
+        cases += get_hash_cases(BLEND_FILE_FOLDER, HASHCODE_FILE, OUTPUT_FOLDER)
+        if RUN_IMAGES_AND_ANIMATIONS:
+            cases+=get_hash_cases(ANIM_BLEND_FILE_FOLDER, HASHCODE_FILE, ANIM_OUTPUT_FOLDER)
+        
+    if len(OPTIONAL_CASES) > 0:
+        if BUILDING_TESTS == False:
+            if HASHCODE_TEST == True:
+                for case in OPTIONAL_CASES:
+                    case[0].setup_hash(case[1], HASHCODE_FILE, case[3])
+            else:
+                for case in OPTIONAL_CASES:
+                    case[0].setup_image(case[1], case[2], case[3])
+                    cases.append(case[0])
+        else:
+            for case in OPTIONAL_CASES:
+                case[0].setup_image(case[1], '', case[2])
+                cases.append(case[0])
+                
+    cases.sort(key=lambda case: case.name)
 
     # Run cases
     for test_case in cases:





More information about the Bf-blender-cvs mailing list