[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54877] trunk/blender/source/tests: add ctest for keyconfig_utils to check for missing items.

Campbell Barton ideasman42 at gmail.com
Tue Feb 26 05:48:17 CET 2013


Revision: 54877
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54877
Author:   campbellbarton
Date:     2013-02-26 04:48:16 +0000 (Tue, 26 Feb 2013)
Log Message:
-----------
add ctest for keyconfig_utils to check for missing items.

Modified Paths:
--------------
    trunk/blender/source/tests/CMakeLists.txt

Added Paths:
-----------
    trunk/blender/source/tests/bl_keymap_completeness.py

Modified: trunk/blender/source/tests/CMakeLists.txt
===================================================================
--- trunk/blender/source/tests/CMakeLists.txt	2013-02-26 03:35:15 UTC (rev 54876)
+++ trunk/blender/source/tests/CMakeLists.txt	2013-02-26 04:48:16 UTC (rev 54877)
@@ -46,6 +46,10 @@
 
 # ------------------------------------------------------------------------------
 # GENERAL PYTHON CORRECTNESS TESTS
+add_test(script_load_keymap ${TEST_BLENDER_EXE}
+	--python ${CMAKE_CURRENT_LIST_DIR}/bl_keymap_completeness.py
+)
+
 add_test(script_load_addons ${TEST_BLENDER_EXE}
 	--python ${CMAKE_CURRENT_LIST_DIR}/bl_load_addons.py
 )

Added: trunk/blender/source/tests/bl_keymap_completeness.py
===================================================================
--- trunk/blender/source/tests/bl_keymap_completeness.py	                        (rev 0)
+++ trunk/blender/source/tests/bl_keymap_completeness.py	2013-02-26 04:48:16 UTC (rev 54877)
@@ -0,0 +1,68 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+# simple script to test 'keyconfig_utils' contains correct values.
+
+
+from bpy_extras import keyconfig_utils
+
+
+def check_maps():
+    maps = set()
+
+    def fill_maps(ls):
+        for entry in ls:
+            maps.add(entry[0])
+            fill_maps(entry[3])
+
+    fill_maps(keyconfig_utils.KM_HIERARCHY)
+
+    import bpy
+    maps_bl = set(bpy.context.window_manager.keyconfigs.active.keymaps.keys())
+
+    err = False
+    # Check keyconfig contains only maps that exist in blender
+    test = maps - maps_bl
+    if test:
+        print("Keymaps that are in 'keyconfig_utils' but not blender")
+        for km_id in sorted(test):
+            print("\t%s" % km_id)
+        err = True
+
+    test = maps_bl - maps
+    if test:
+        print("Keymaps that are in blender but not in 'keyconfig_utils'")
+        for km_id in sorted(test):
+            print("\t%s" % km_id)
+        err = True
+
+    return err
+
+
+def main():
+    err = check_maps()
+
+    if err and bpy.app.background:
+        # alert CTest we failed
+        import sys
+        sys.exit(1)
+
+if __name__ == "__main__":
+    main()


Property changes on: trunk/blender/source/tests/bl_keymap_completeness.py
___________________________________________________________________
Added: svn:eol-style
   + native




More information about the Bf-blender-cvs mailing list