[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29195] branches/soc-2010-leifandersen: NOTE THAT THIS VERSION WILL ONLY WORK ON NON-APPLE UNIX.

Leif Andersen leif.a.andersen at gmail.com
Thu Jun 3 22:00:47 CEST 2010


Revision: 29195
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29195
Author:   leifandersen
Date:     2010-06-03 22:00:47 +0200 (Thu, 03 Jun 2010)

Log Message:
-----------
NOTE THAT THIS VERSION WILL ONLY WORK ON NON-APPLE UNIX.

1. The python files are now copied to the binary directories themselves, which means that they are no longer dependant that the source directory moves.

a.  To do this though, I had to add the custom command in the creator's CMakeLists.txt file, which seems odd, if anyone knows how to get ADD_CUSTOM_COMMAND() to work without being in that file, I would appreciate the help.

b.  The process is still a bit rough, and leaves the other testing source files in the testing folder.  Also, only the non-apple unix coommands have been added, meaning that mosts of the tests will fail on any other platform.

c.  This also fixes the problem when reading paths, because ctest runns them relative to their direcotry in the binary folder.

2.  Started a lamp unit test, in hopes for finding other useful forms of agregations.

3.  Set scenes up to use the tests module.

Proposals:
1. I'm thinking the the hashtests and pyunit tests should really be in the same place.  The hashtests use the pyunit framework anyway, and the module makes it accesable to both.

2. I'm considering modifying one of the importers to import files specifically for hash testiing.   This would be a bad idea for other unit tests because it wouldn't guarentee that all of the api calls are ran (I think).

Bug:  Once in a while the gtest command fails to run with ctest, saying it's a 'bad command', but this is inconsistant.

Modified Paths:
--------------
    branches/soc-2010-leifandersen/release/scripts/modules/tests/__init__.py
    branches/soc-2010-leifandersen/release/scripts/modules/tests/scenes.py
    branches/soc-2010-leifandersen/source/creator/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt
    branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py

Added Paths:
-----------
    branches/soc-2010-leifandersen/release/scripts/modules/tests/lamps.py
    branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py

Modified: branches/soc-2010-leifandersen/release/scripts/modules/tests/__init__.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/__init__.py	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/__init__.py	2010-06-03 20:00:47 UTC (rev 29195)
@@ -16,4 +16,4 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-from tests import scenes, objects, meshes, hashfile, build
+from tests import scenes, objects, meshes, lamps, hashfile, build

Added: branches/soc-2010-leifandersen/release/scripts/modules/tests/lamps.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/lamps.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/lamps.py	2010-06-03 20:00:47 UTC (rev 29195)
@@ -0,0 +1,7 @@
+import bpy
+
+def reset_lamps():
+    while len(bpy.data.lamps) > 0:
+        bpy.data.lamps[0].user_clear()
+        bpy.data.lamps.remove(bpy.data.lamps[0])
+

Modified: branches/soc-2010-leifandersen/release/scripts/modules/tests/scenes.py
===================================================================
--- branches/soc-2010-leifandersen/release/scripts/modules/tests/scenes.py	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/release/scripts/modules/tests/scenes.py	2010-06-03 20:00:47 UTC (rev 29195)
@@ -43,7 +43,3 @@
     if bpy.data.scenes[0].name != "Test":
         bpy.data.scenes.new("Test")
         bpy.data.scenes.remove(bpy.data.scenes[1])
-
-if __name__ == "__main__":
-    for scene in bpy.data.scenes:
-        print(scene.name+": "+str(hashcode(scene)))

Modified: branches/soc-2010-leifandersen/source/creator/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/source/creator/CMakeLists.txt	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/source/creator/CMakeLists.txt	2010-06-03 20:00:47 UTC (rev 29195)
@@ -176,6 +176,13 @@
      
 		ENDIF(WITH_PYTHON)
       
+
+		IF(WITH_TESTS)
+			ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDANCY blender
+				COMMAND cp -R ${Blender_SOURCE_DIR}/tests ${Blender_BINARY_DIR} 
+			)	
+		ENDIF(WITH_TESTS)
+		
 		ADD_CUSTOM_COMMAND(
 			TARGET blender POST_BUILD MAIN_DEPENDENCY blender
 			COMMAND find ${TARGETDIR} -name .svn -prune -exec rm -rf {} "\;"

Modified: branches/soc-2010-leifandersen/tests/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/CMakeLists.txt	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/tests/CMakeLists.txt	2010-06-03 20:00:47 UTC (rev 29195)
@@ -23,7 +23,7 @@
 # Contributor(s): Andrea Weikert, Leif Andersen.
 #
 # ***** END GPL LICENSE BLOCK *****
-
+ENABLE_TESTING()
 ADD_SUBDIRECTORY(gtest)
 ADD_SUBDIRECTORY(pyunit)
 ADD_SUBDIRECTORY(hashtests)

Modified: branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/tests/hashtests/CMakeLists.txt	2010-06-03 20:00:47 UTC (rev 29195)
@@ -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 ${Blender_SOURCE_DIR}/tests/hashtests/scenehashes.txt)
+ADD_TEST(HashTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/hashtests/scenes.py)
 SET_TESTS_PROPERTIES(HashTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")

Modified: branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/tests/pyunit/CMakeLists.txt	2010-06-03 20:00:47 UTC (rev 29195)
@@ -31,6 +31,3 @@
 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
-)

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/CMakeLists.txt	2010-06-03 20:00:47 UTC (rev 29195)
@@ -1,5 +1,10 @@
-add_test(DataMeshTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_SOURCE_DIR}/tests/pyunit/data/meshes.py)
-set_tests_properties(DataMeshTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(DataMeshTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/meshes.py)
+SET_TESTS_PROPERTIES(DataMeshTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
 
-add_test(DataSceneTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_SOURCE_DIR}/tests/pyunit/data/scenes.py)
-set_tests_properties(DataSceneTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+ADD_TEST(DataSceneTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/scenes.py)
+SET_TESTS_PROPERTIES(DataSceneTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+ADD_TEST(DataLampTest ${Blender_BINARY_DIR}/bin/blender -b -P ${Blender_BINARY_DIR}/tests/pyunit/data/lamps.py)
+SET_TESTS_PROPERTIES(DataLampTest PROPERTIES PASS_REGULAR_EXPRESSION "OK")
+
+

Added: branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py	                        (rev 0)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/lamps.py	2010-06-03 20:00:47 UTC (rev 29195)
@@ -0,0 +1,16 @@
+import bpy
+import tests
+import unittest
+
+class TestLampCreationAndRemoval(unittest.TestCase):
+    def setUp(self):
+        tests.lamps.reset_lamps()
+
+    def test_lamp_creation(self):
+        pass
+
+def suite():
+    return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestLampCreationAndRemoval)])
+
+if __name__ == "__main__":
+    unittest.TextTestRunner(verbosity=2).run(suite())

Modified: branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py
===================================================================
--- branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py	2010-06-03 19:56:13 UTC (rev 29194)
+++ branches/soc-2010-leifandersen/tests/pyunit/data/scenes.py	2010-06-03 20:00:47 UTC (rev 29195)
@@ -1,9 +1,10 @@
 import unittest
 import random
+import tests
 
 class TestSceneCreationAndRemoval(unittest.TestCase):
     def setUp(self):
-        reset_scenes()
+        tests.scenes.reset_scenes()
 
     def test_scene_count(self):
         self.assertEqual(1,len(bpy.data.scenes))
@@ -59,7 +60,7 @@
 
 class TestDataStructTypes(unittest.TestCase):
     def setUp(self):
-        reset_scenes()
+        tests.scenes.reset_scenes()
 
     def test_rna_type(self):
         # Simply tests the RNA type based on the string that is outputted from the API call
@@ -89,7 +90,7 @@
         self.assertEquals(count_add-count_delete+1,len(bpy.data.scenes.keys()))
 
         # Test to ensure that the key array isn't too long
-        reset_scenes()
+        tests.scenes.reset_scenes()
         self.assertEquals('Test', bpy.data.scenes.keys()[0])
         try:
             bpy.data.scenes.remove(bpy.data.scenes.keys()[1])
@@ -110,7 +111,7 @@
 
 class TestSceneAPICalls(unittest.TestCase):
     def setUp(self):
-        reset_scenes()
+        tests.scenes.reset_scenes()
 
     def test_default_layers(self):
         # Tests the default layer properties (visability, count, etc.)
@@ -140,19 +141,9 @@
             count_delete = temp
         return (count_add, count_delete)
 
-def reset_scenes():
-    # Assuming the default blend file, or a file that has only been modified by one of the
-    # tests in this suite, it will clear all of the scenes, and create one that it calls "Test"
-    bpy.data.scenes.new("Test")
-    while len(bpy.data.scenes) > 1:
-        bpy.data.scenes.remove(bpy.data.scenes[0])
-    if bpy.data.scenes[0].name != "Test":
-        bpy.data.scenes.new("Test")
-        bpy.data.scenes.remove(bpy.data.scenes[1])
 
-
 def suite():
     return unittest.TestSuite([unittest.TestLoader().loadTestsFromTestCase(TestSceneCreationAndRemoval), unittest.TestLoader().loadTestsFromTestCase(TestDataStructTypes), unittest.TestLoader().loadTestsFromTestCase(TestSceneAPICalls)])
 
 if __name__ == "__main__":
-    unittest.TextTestRunner(verbosity=2).run(suite())
\ No newline at end of file
+    unittest.TextTestRunner(verbosity=2).run(suite())





More information about the Bf-blender-cvs mailing list