From bba6b535dee7e91f13b88cb706e8f94bfc273c90 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Feb 2013 04:48:16 +0000 Subject: add ctest for keyconfig_utils to check for missing items. --- source/tests/bl_keymap_completeness.py | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 source/tests/bl_keymap_completeness.py (limited to 'source/tests/bl_keymap_completeness.py') diff --git a/source/tests/bl_keymap_completeness.py b/source/tests/bl_keymap_completeness.py new file mode 100644 index 00000000000..d36f2d8e9ae --- /dev/null +++ b/source/tests/bl_keymap_completeness.py @@ -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 ##### + +# + +# 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() -- cgit v1.2.3