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

Leif Andersen leif.a.andersen at gmail.com
Thu Jul 29 22:08:14 CEST 2010


Revision: 30879
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30879
Author:   leifandersen
Date:     2010-07-29 22:08:14 +0200 (Thu, 29 Jul 2010)

Log Message:
-----------
1.  Moved some of the hashcode operators so that it is placed in the actual operators.  (Added a gui too, but that's not the main focus)

2.  Removed the mancandy files from the animations, as they seemed pointless.

3.  Changed run.py to always build the tests (making the documentation obsolete). (Assumes the user has a good copy of blender in his/her path, otherwise the --good-blender-bin flag can be used).

4.  Due to #3, removed all pre-built renders, taking all of the tests down to ~10 MB in size.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/release/scripts/modules/tests/hashfile.py
    branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py
    branches/soc-2010-leifandersen/release/scripts/ui/space_tests.py
    branches/soc-2010-leifandersen/tests/render/run.py

Removed Paths:
-------------
    branches/soc-2010-leifandersen/tests/render/anim/mancandy_actiondeform.blend
    branches/soc-2010-leifandersen/tests/render/anim/mancandy_matching.blend
    branches/soc-2010-leifandersen/tests/render/render/

Modified: branches/soc-2010-leifandersen/release/scripts/modules/tests/hashfile.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/hashfile.py	2010-07-29 17:14:50 UTC (rev 30878)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/hashfile.py	2010-07-29 20:08:14 UTC (rev 30879)
@@ -31,28 +31,6 @@
 [['empty_scene', -1504849438355502056], ['empty_mesh', 3297148919719683587]]
 """
 
-# Writes a hash file based on the path given, and the data tuple array given.
-def write(file, data):
-	file = open(file, 'w')
-	for tuple in data:
-		file.write(tuple[0]+" = "+str(tuple[1])+"\n")
-	file.close()
-	return
-
-# Creates a data tuple array of hashes based on the hashfile path given
-def read(file):
-	file = open(file, 'r')
-	line = file.readline()
-	data = []
-	while line != "":
-		while line.strip().startswith('#') or line.startswith("\n") or line.isspace():
-			line = file.readline()
-		split = line.split()
-		data.append([split[0],int(split[2])])
-		line = file.readline()
-	file.close()
-	return data
-
 # Changes the value of a hash in a hashfile.  If you have multiple hashes in the same hashfile that share the same name, than you have the option of returning which hash in the file it has that name.
 #param: pathname, hashname, new hash code, hash location (only needed for clashing names)
 def changehash(path, hashname, hashcode, number=1):
@@ -67,4 +45,5 @@
     data[change_index][1] = hashcode
     tests.hashfile.write(path, data)
 
-last_hash = -1
\ No newline at end of file
+last_hash = -1
+data = []
\ No newline at end of file

Modified: branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py	2010-07-29 17:14:50 UTC (rev 30878)
+++ branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py	2010-07-29 20:08:14 UTC (rev 30879)
@@ -58,14 +58,91 @@
                                 for num in hair.location:
                                     hashcode += hash(num)         
         print(hashcode)
-        tests.hashfile.last_hash = hashcode
+        tests.hashfile.last_hash = hashcode 
         return {'FINISHED'}
+    
+    def invoke(self, context, event):
+        return {'RUNNING_MODAL'}
 
+class TESTS_OT_write_hashfile(bpy.types.Operator):
+    '''Writes the current hash set stored into a hashfile'''
+    bl_idname = "TESTS_OT_write_hashfile"
+    bl_label = "Write Hash File"
+    
+    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 len(tests.data) < 0
+    
+    def execute(self, context):
+        file = open(self.properties.filepath, 'w')
+        for tuple in tests.data:
+            file.write(tuple[0] + " = " + str(tuple[1]) + "\n")
+        file.close()
+        return {'FINISHED'}
+    
     def invoke(self, context, event):
+        wm = context.manager
+        wm.add_fileselect(self)
         return {'RUNNING_MODAL'}
 
+class TESTS_OT_read_hashfile(bpy.types.Operator):
+    '''Writes the current hash set stored into a hashfile'''
+    bl_idname = "TESTS_OT_read_hashfile"
+    bl_label = "Read Hash File"
+    
+    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):
+        try:
+            file = open(self.properties.filepath, 'r')
+            try:
+                line = file.readline()
+                tests.data = []
+                while line != "":
+                    while line.strip().startswith('#') or line.startswith("\n") or line.isspace():
+                        line = file.readline()
+                    split = line.split()
+                    tests.data.append([split[0],int(split[2])])
+                    line = file.readline()
+                file.close()
+                return {'FINISHED'}
+            except:
+                file.close()
+                return {'CANCELLED'}
+        except:
+            return {'CANCELLED'}
+
+    def invoke(self, context, event):
+        wm = context.manager
+        wm.add_fileselect(self)
+        return {'RUNNING_MODAL'}
+
+# Creates a data tuple array of hashes based on the hashfile path given
+def read(file):
+    file = open(file, 'r')
+    line = file.readline()
+    data = []
+    while line != "":
+        while line.strip().startswith('#') or line.startswith("\n") or line.isspace():
+            line = file.readline()
+        split = line.split()
+        data.append([split[0],int(split[2])])
+        line = file.readline()
+    file.close()
+    return data
+
 classes = [
     TESTS_OT_hash,
+    TESTS_OT_write_hashfile,
+    TESTS_OT_read_hashfile,
 ]
     
 def register():

Modified: branches/soc-2010-leifandersen/release/scripts/ui/space_tests.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/ui/space_tests.py	2010-07-29 17:14:50 UTC (rev 30878)
+++ branches/soc-2010-leifandersen/release/scripts/ui/space_tests.py	2010-07-29 20:08:14 UTC (rev 30879)
@@ -16,6 +16,8 @@
         layout.operator("TESTS_OT_anim_build", text="Build Animation Test")
         layout.separator()
         layout.operator("TESTS_OT_hash", text="File Hash")
+        layout.operator("TESTS_OT_read_hashfile", text="Read Hashfile")
+        layout.operator("TESTS_OT_write_hashfile", text="Write Hashfile")
 
 class TestsPanel(bpy.types.Panel):
     bl_space_type = 'VIEW_3D'

Deleted: branches/soc-2010-leifandersen/tests/render/anim/mancandy_actiondeform.blend
===================================================================
(Binary files differ)

Deleted: branches/soc-2010-leifandersen/tests/render/anim/mancandy_matching.blend
===================================================================
(Binary files differ)

Modified: branches/soc-2010-leifandersen/tests/render/run.py
===================================================================
--- branches/soc-2010-leifandersen/tests/render/run.py	2010-07-29 17:14:50 UTC (rev 30878)
+++ branches/soc-2010-leifandersen/tests/render/run.py	2010-07-29 20:08:14 UTC (rev 30879)
@@ -382,7 +382,7 @@
             cases.append(test_case)
     return cases
 
-def console_output(cases, building_tests):
+def console_output(cases):
     '''Displays the final output to the console.
        building_tests: Whether or not the tests were being built
        get_hashcodes: Whether or not the hashcodes are needed to be displayed'''
@@ -390,11 +390,6 @@
     failed = []
 
     print ''
-    
-    # Print finished and return in case the tests were just being built
-    if building_tests:
-        print "Tests built successfully"
-        return
 
     # Print failed test cases
     for test_case in cases:
@@ -403,18 +398,12 @@
 
     # Print the failed tests, or, if all tests passed, print that
     if len(failed) > 0:
-        print "The following tesets failed:"
+        print "The following tests failed:"
         for test_case in failed:
             print test_case.name
     else:
         print "All tests passed"
         
-    # If everything failed, maybe the test wasn't initialized
-    if len(failed) == len(cases) and len(cases) != 0:
-        print ''
-        print "It is possible that the tests have not been built, if so"
-        print "Please build tests by running: python run.py --build-tests"
-        print "Or python --build-tests --with-animations to also build animation tests"
     print 'Check index.html for more information'
 
 def anim_output(animation, output_path):
@@ -581,8 +570,6 @@
 
     # Parse the arguements
     parser = OptionParser()
-    parser.add_option('--build-tests', action='store_true', dest='building_tests', default=False,
-                      help="Render the images for the tests")
     parser.add_option('--blender-bin', '-b', type='string', dest='blender_bin', default='blender',
                       help="Location of the blender binary if not in your path.")
     parser.add_option('--good-blender-bin', type='string', dest='good_blender_bin', default='blender',
@@ -603,57 +590,70 @@
     BLENDER_BIN = options.blender_bin
     VERBOSE = options.verbose
 
-    # Change pointers if building tests
-    if options.building_tests:
-        BLENDER_BIN = GOOD_BLENDER_BIN
-        OUTPUT_FOLDER = GOOD_FOLDER
-        GOOD_FOLDER = ''
-        ANIM_OUTPUT_FOLDER = ANIM_GOOD_FOLDER
-        ANIM_GOOD_FOLDER = ''
+    BLENDER_BIN = GOOD_BLENDER_BIN
+    OUTPUT_FOLDER = GOOD_FOLDER
+    GOOD_FOLDER = ''
+    ANIM_OUTPUT_FOLDER = ANIM_GOOD_FOLDER
+    ANIM_GOOD_FOLDER = ''
 
-    # If there are optional tets listed, determin if their animations or images, and set them up.
-    for arg in args:
-        (directory, file) = os.path.split(arg)
-        if options.image:
-            case = ImageTestCase()
-            optional_cases.append((case, arg, os.path.join(directory, 'render', string.replace(file, '.blend', '_0001.png')), os.path.join(directory, 'output', string.replace(file, '.blend', '')), os.path.join(directory, 'render', string.replace(file, '.blend', ''))))
-        else:
-            case = AnimationTestCase()
-            optional_cases.append((case, arg, os.path.join(directory, string.replace(file, '.blend', '')), os.path.join(directory, 'output', string.replace(file, '.blend', '')), os.path.join(directory, string.replace(file, '.blend', ''))))
+    for i in range(0,2):
+        # If there are optional tets listed, determin if their animations or images, and set them up.
+        for arg in args:
+            (directory, file) = os.path.split(arg)
+            if options.image:
+                case = ImageTestCase()

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list