Rev 2607: Add failing test that global options are used at least twice in http://sourcefrog.net/bzr/check-options
Martin Pool
mbp at sourcefrog.net
Wed Jul 11 05:18:53 BST 2007
At http://sourcefrog.net/bzr/check-options
------------------------------------------------------------
revno: 2607
revision-id: mbp at sourcefrog.net-20070711041852-u0owtlcd1rh9ri37
parent: mbp at sourcefrog.net-20070711041548-n1om2ptyj2j01r6l
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: check-options
timestamp: Wed 2007-07-11 14:18:52 +1000
message:
Add failing test that global options are used at least twice
modified:
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2007-07-11 04:15:48 +0000
+++ b/bzrlib/tests/test_options.py 2007-07-11 04:18:52 +0000
@@ -268,7 +268,7 @@
# are used very widely with the exact same meaning. So this checks
# for any that should be garbage collected.
g = dict(option.Option.OPTIONS.items())
- used_globals = set()
+ used_globals = {}
msgs = []
for cmd_name, cmd_class in sorted(commands.get_all_cmds()):
for option_or_name in sorted(cmd_class.takes_options):
@@ -279,10 +279,14 @@
"global option %r from %r"
% (option_or_name, cmd_class))
else:
- used_globals.add(option_or_name)
- unused_globals = set(g.keys()) - used_globals
+ used_globals.setdefault(option_or_name, []).append(cmd_name)
+ unused_globals = set(g.keys()) - set(used_globals.keys())
for option_name in sorted(unused_globals):
msgs.append("unused global option %r" % option_name)
+ for option_name, cmds in sorted(used_globals.items()):
+ if len(cmds) <= 1:
+ msgs.append("global option %r is only used by %r"
+ % (option_name, cmds))
if msgs:
self.fail("problems with global option definitions:\n"
+ '\n'.join(msgs))
More information about the bazaar-commits
mailing list