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

Leif Andersen leif.a.andersen at gmail.com
Mon Aug 2 05:01:38 CEST 2010


Revision: 30962
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30962
Author:   leifandersen
Date:     2010-08-02 05:01:37 +0200 (Mon, 02 Aug 2010)

Log Message:
-----------
1.  Started adding the import tests.

2.  Improoved the hashcode operator.

3.  Integrated into CTest (due to a few remaining limitations to the API, a little more than I would like).

4.  You can now optionally use pre-built render tests.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py
    branches/soc-2010-leifandersen/tests/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py
    branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py
    branches/soc-2010-leifandersen/tests/pyunit/data/objects.py
    branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py
    branches/soc-2010-leifandersen/tests/render/run.py

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/export_import_testing/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/export_import_testing/export_import_testing.py
    branches/soc-2010-leifandersen/tests/export_import_testing/hashfile.txt
    branches/soc-2010-leifandersen/tests/hashfile.txt

Modified: branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py	2010-08-02 02:55:12 UTC (rev 30961)
+++ branches/soc-2010-leifandersen/release/scripts/op/tests_hash.py	2010-08-02 03:01:37 UTC (rev 30962)
@@ -43,6 +43,10 @@
                     for vert in ob.data.verts:
                         for co in vert.co:
                             hashcode += hash(co)
+                    for face in ob.data.faces:
+                        hashcode += hash(face)
+                    for num in ob.data.edge_face_count:
+                        hashcode += hash(num)
                     for ps in ob.particle_systems:
                         hashcode += hash(ps.editable)
                         hashcode += hash(ps.edited)
@@ -78,7 +82,7 @@
     
     def execute(self, context):
         file = open(self.properties.filepath, 'w')
-        for tuple in tests.data:
+        for tuple in tests.hashfile.data:
             file.write(tuple[0] + " = " + str(tuple[1]) + "\n")
         file.close()
         return {'FINISHED'}
@@ -110,7 +114,7 @@
                     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])])
+                    tests.hashfile.data.append([split[0],int(split[2])])
                     line = file.readline()
                 file.close()
                 return {'FINISHED'}
@@ -125,20 +129,6 @@
         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,

Modified: branches/soc-2010-leifandersen/tests/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/CMakeLists.txt	2010-08-02 02:55:12 UTC (rev 30961)
+++ branches/soc-2010-leifandersen/tests/CMakeLists.txt	2010-08-02 03:01:37 UTC (rev 30962)
@@ -25,6 +25,7 @@
 # ***** END GPL LICENSE BLOCK *****
 ENABLE_TESTING()
 ADD_SUBDIRECTORY(pyunit)
+ADD_SUBDIRECTORY(export_import_testing)
 
 ADD_TEST(Image_Diffs python ${Blender_BINARY_DIR}/tests/render/run.py --blender-bin ${Blender_BINARY_DIR}/bin/blender)
 SET_TESTS_PROPERTIES(Image_Diffs PROPERTIES PASS_REGULAR_EXPRESSION "All tests passed")

Added: branches/soc-2010-leifandersen/tests/export_import_testing/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/export_import_testing/CMakeLists.txt	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/export_import_testing/CMakeLists.txt	2010-08-02 03:01:37 UTC (rev 30962)
@@ -0,0 +1,42 @@
+ADD_TEST(EI_All_Quads ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/all_quads.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(EI_All_Quads PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(EI_All_Tris ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/all_tris.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(EI_All_Tris PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(EI_Edges ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/edges.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(EI_Edges PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(EI_Fgons ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/fgons.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(EI_Fgons PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(Mixed_Quads_And_Tris ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/mixed_quads_and_tris.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(Mixed_Quads_And_Tris PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(EI_Nurbs ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/NURBS.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(EI_Nurbs PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(EI_Vertices ${Blender_BINARY_DIR}/bin/blender 
+	-b ${Blender_BINARY_DIR}/tests/export_import_testing/MESH_GEOMETRY/vertices.blend
+	-P  ${Blender_BINARY_DIR}/tests/export_import_testing/export_import_testing.py
+)
+SET_TESTS_PROPERTIES(EI_Vertices PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+

Added: branches/soc-2010-leifandersen/tests/export_import_testing/export_import_testing.py
===================================================================
--- branches/soc-2010-leifandersen/tests/export_import_testing/export_import_testing.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/export_import_testing/export_import_testing.py	2010-08-02 03:01:37 UTC (rev 30962)
@@ -0,0 +1,28 @@
+import bpy
+import tests
+
+import unittest
+import sys
+import os
+
+data = []
+
+class TestCurrentFile(unittest.TestCase):
+    
+    def setUp(self):
+        pass
+    
+    def test_all_quads(self):
+        bpy.ops.tests.hash()
+        self.assertEquals(data[0][1], tests.hashfile.last_hash)
+
+def suite():
+    return unittest.TestSuite([
+unittest.TestLoader().loadTestsFromTestCase(TestCurrentFile),
+])
+
+if __name__ == "__main__":
+    print(bpy.ops.tests.read_hashfile(filepath="hashfile.txt"))
+    data = tests.hashfile.data
+    unittest.TextTestRunner(verbosity=2).run(suite())
+    bpy.ops.wm.exit_blender()
\ No newline at end of file

Added: branches/soc-2010-leifandersen/tests/export_import_testing/hashfile.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/export_import_testing/hashfile.txt	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/export_import_testing/hashfile.txt	2010-08-02 03:01:37 UTC (rev 30962)
@@ -0,0 +1 @@
+all_quads = 4476784380650705631

Added: branches/soc-2010-leifandersen/tests/hashfile.txt
===================================================================

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py	2010-08-02 02:55:12 UTC (rev 30961)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py	2010-08-02 03:01:37 UTC (rev 30962)
@@ -4,7 +4,7 @@
 
 class TestLampCreationAndRemoval(unittest.TestCase):
     def setUp(self):
-     	bpy.ops.wm.read_homefile(factory=True)
+        bpy.ops.wm.read_homefile(factory=True)
 
     def test_lamp_creation(self):
         pass
@@ -14,3 +14,5 @@
 
 if __name__ == "__main__":
     unittest.TextTestRunner(verbosity=2).run(suite())
+    bpy.ops.wm.exit_blender()
+

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py	2010-08-02 02:55:12 UTC (rev 30961)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/meshes.py	2010-08-02 03:01:37 UTC (rev 30962)
@@ -26,3 +26,4 @@
 
 if __name__ == "__main__":
     unittest.TextTestRunner(verbosity=2).run(suite())
+    bpy.ops.wm.exit_blender()

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/objects.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/objects.py	2010-08-02 02:55:12 UTC (rev 30961)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/objects.py	2010-08-02 03:01:37 UTC (rev 30962)
@@ -7,7 +7,7 @@
 class TestObjectProperties(unittest.TestCase):
     def setUp(self):
 #       TODO (see next class below)
-        tests.objects.reset_objects()
+        bpy.ops.wm.read_homefile(factory=True)
 
     def test_object_matrix(self):
         object = bpy.data.objects.new("Object", None)
@@ -25,7 +25,7 @@
     def setUp(self):
 #       eventually change it to do the commented line of code, but for now, it causes segfaults, do to some bug in blender
 #       TODO, fix the bug
-        tests.objects.reset_objects()
+        bpy.ops.wm.read_homefile(factory=True)
 
     def test_object_relationship(self):
         parent = bpy.data.objects.new("Parent", None)
@@ -71,3 +71,4 @@
 
 if __name__ == "__main__":
     unittest.TextTestRunner(verbosity=2).run(suite())
+    bpy.ops.wm.exit_blender()

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py	2010-08-02 02:55:12 UTC (rev 30961)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py	2010-08-02 03:01:37 UTC (rev 30962)
@@ -16,13 +16,12 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
+import bpy
 
 import unittest
 import random
 import tests
 
-from tests.scenes import hashcode
-
 # A list of all of the hash codes
 # TODO:  Add an easier way to update?
 path = "scenehashes.txt"
@@ -33,12 +32,10 @@
 
 class TestSceneCreationAndRemoval(unittest.TestCase):
     def setUp(self):
-	bpy.ops.wm.read_homefile()
-	bpy.data.scenes.new("Test")
-	bpy.data.scenes.remove(bpy.data.scenes['Scene'])
+        bpy.ops.wm.read_homefile(factory=True)
+        bpy.data.scenes.new("Test")
+        bpy.data.scenes.remove(bpy.data.scenes['Scene'])
 
-        tests.scenes.reset_scenes()
-
     def test_scene_count(self):
         self.assertEqual(1,len(bpy.data.scenes))
 
@@ -93,7 +90,7 @@
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list