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

Leif Andersen leif.a.andersen at gmail.com
Tue Jun 1 02:16:51 CEST 2010


Revision: 29114
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29114
Author:   leifandersen
Date:     2010-06-01 02:16:51 +0200 (Tue, 01 Jun 2010)

Log Message:
-----------
1.  Rolled back the algorithm in the scenes hashtest test, because I realized that it wouldn't work on any path except my own.

2.  Moved the hashcodes.txt file to scenehashes.txt, in an attempt to make it expand better.

3.  Attempting to find ways to read files relitive to the binary directory without popping up a file chooser.

4.  Attempted, and failed (thusfar), to automate copying the test scripts over to the binary directory when testing is enabled.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/hashtests/hashchanger.py
    branches/soc-2010-leifandersen/tests/hashtests/scenes.py
    branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt

Added Paths:
-----------
    branches/soc-2010-leifandersen/tests/hashtests/scenehashes.txt

Removed Paths:
-------------
    branches/soc-2010-leifandersen/tests/hashtests/hashcodes.txt

Modified: branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt	2010-05-31 23:46:08 UTC (rev 29113)
+++ branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt	2010-06-01 00:16:51 UTC (rev 29114)
@@ -24,5 +24,5 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
-ADD_TEST(HashTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_SOURCE_DIR}/tests/hashtests/scenes.py)
+ADD_TEST(HashTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_SOURCE_DIR}/tests/hashtests/scenes.py ${Blender_SOURCE_DIR}/tests/hashtests/scenehashes.txt)
 SET_TESTS_PROPERTIES(HashTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")

Modified: branches/soc-2010-leifandersen/tests/hashtests/hashchanger.py
===================================================================
--- branches/soc-2010-leifandersen/tests/hashtests/hashchanger.py	2010-05-31 23:46:08 UTC (rev 29113)
+++ branches/soc-2010-leifandersen/tests/hashtests/hashchanger.py	2010-06-01 00:16:51 UTC (rev 29114)
@@ -1,17 +1,40 @@
-import tests
-import sys
+import bpy
+from rna_prop_ui import PropertyPanel
 
-def changehash(path, hashname, hashcode, number=1):
-    data = tests.hashfile.read(path)
-    hash_locations = []
-    i = 0
-    for tuple in data:
-        if tuple[0] == hashname:
-            hash_locations.append(i)
-    i+=1
-    change_index = hash_locations[number-1]
-    data[change_index][1] = hashcode
-    tests.hashfile.write(path, data)
+class Path:
+    __slots__ = 'path'
 
+class TESTS_header(bpy.types.Header):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'UI'
+    def draw(self, context):
+        layout = self.layout
+        
+
+class TESTS_hashfile(bpy.types.Panel):
+    bl_label = "Hashfile operations"
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    path = Path()
+    def draw(self, context):
+        layout = self.layout
+        row = layout.row()
+        row.label("foo")
+        row.prop_enum(path, path)
+    
+classes = [
+TESTS_header,
+TESTS_hashfile]
+    
+def register():
+    register = bpy.types.register
+    for c in classes:
+        register(c)
+
+def unregister():
+    unregister = bpy.types.unregister
+    for c in classes:
+        unregister(c)
+    
 if __name__ == '__main__':
-    changehash("/home/leif/blender-svn/soc-2010-leifandersen/tests/hashtests/hashcodes.txt", "empty_scene", -1504849438355502056)
+    register()
\ No newline at end of file

Deleted: branches/soc-2010-leifandersen/tests/hashtests/hashcodes.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/hashtests/hashcodes.txt	2010-05-31 23:46:08 UTC (rev 29113)
+++ branches/soc-2010-leifandersen/tests/hashtests/hashcodes.txt	2010-06-01 00:16:51 UTC (rev 29114)
@@ -1,2 +0,0 @@
-empty_scene = -1504849438355502056
-empty_mesh = 3297148919719683587

Copied: branches/soc-2010-leifandersen/tests/hashtests/scenehashes.txt (from rev 29093, branches/soc-2010-leifandersen/tests/hashtests/hashcodes.txt)
===================================================================
--- branches/soc-2010-leifandersen/tests/hashtests/scenehashes.txt	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/hashtests/scenehashes.txt	2010-06-01 00:16:51 UTC (rev 29114)
@@ -0,0 +1,2 @@
+empty_scene = -1504849438355502056
+empty_mesh = 3297148919719683587

Modified: branches/soc-2010-leifandersen/tests/hashtests/scenes.py
===================================================================
--- branches/soc-2010-leifandersen/tests/hashtests/scenes.py	2010-05-31 23:46:08 UTC (rev 29113)
+++ branches/soc-2010-leifandersen/tests/hashtests/scenes.py	2010-06-01 00:16:51 UTC (rev 29114)
@@ -25,10 +25,11 @@
 
 # A list of all of the hash codes
 # TODO:  Add an easier way to update?
-path = "/home/leif/blender-svn/soc-2010-leifandersen/tests/hashtests/hashcodes.txt"
+path = "/home/leif/blender-svn/soc-2010-leifandersen/tests/hashtests/scenehashes.txt"
 
-empty_scene = 0
-empty_mesh = 0
+empty_scene = -1504849438355502056
+empty_mesh = 3297148919719683587
+cube_mesh = 0
 
 class TestEmptyScene(unittest.TestCase):
     def setUp(self):
@@ -39,12 +40,19 @@
     def test_empy_scene(self):
         self.assertEqual(empty_scene, hashcode(bpy.data.scenes[0]))
 
-    def test_cube_scene(self):
+    def test_empty_mesh_scene(self):
         mesh = bpy.data.meshes.new("Test")
         obj = bpy.data.objects.new("Test", mesh)
         bpy.data.scenes[0].objects.link(obj)
         self.assertEquals(empty_mesh, hashcode(bpy.data.scenes[0]))
 
+    def test_cube_mesh_scene(self):
+        mesh=bpy.data.meshes.new("Cube")
+        obj = bpy.data.objects.new("Cube",mesh)
+        bpy.data.scenes[0].objects.link(obj)
+        mesh.add_geometry(6,0,8)
+        self.assertEquals(cube_mesh, hashcode(bpy.data.scenes[0]))
+
 def rand_pos_int():
     return random.randint(0, 2000)
 
@@ -64,7 +72,7 @@
     return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestEmptyScene)])
 
 if __name__ == "__main__":
-    hashlist = tests.hashfile.read(path)
-    empty_scene = hashlist[0][1]
-    empty_mesh = hashlist[1][1]
+#    hashlist = tests.hashfile.read(path)
+#    empty_scene = hashlist[0][1]
+#    empty_mesh = hashlist[1][1]
     unittest.TextTestRunner(verbosity=2).run(suite())
\ No newline at end of file

Modified: branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt	2010-05-31 23:46:08 UTC (rev 29113)
+++ branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt	2010-06-01 00:16:51 UTC (rev 29114)
@@ -31,3 +31,6 @@
 add_subdirectory(props)
 add_subdirectory(types)
 add_subdirectory(utils)
+ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDANCY blender
+	COMMAND mkdir /home/leif/blender-build/foobar
+)





More information about the Bf-blender-cvs mailing list