2671
2672
return self.tests.has_key(test_id)
2675
class TestPrefixAliasRegistry(registry.Registry):
2676
"""A registry for test prefix aliases.
2678
This helps implement shorcuts for the --starting-with selftest
2679
option. Overriding existing prefixes is not allowed but not fatal (a
2680
warning will be emitted).
2683
def register(self, key, obj, help=None, info=None,
2684
override_existing=False):
2685
"""See Registry.register.
2687
Trying to override an existing alias causes a warning to be emitted,
2688
not a fatal execption.
2691
super(TestPrefixAliasRegistry, self).register(
2692
key, obj, help=help, info=info, override_existing=False)
2694
actual = self.get(key)
2695
note('Test prefix alias %s is already used for %s, ignoring %s'
2696
% (key, actual, obj))
2698
def resolve_alias(self, id_start):
2699
"""Replace the alias by the prefix in the given string.
2701
Using an unknown prefix is an error to help catching typos.
2703
parts = id_start.split('.')
2705
parts[0] = self.get(parts[0])
2707
raise errors.BzrCommandError(
2708
'%s is not a known test prefix alias' % parts[0])
2709
return '.'.join(parts)
2712
test_prefix_alias_registry = TestPrefixAliasRegistry()
2713
"""Registry of test prefix aliases."""
2716
# This alias allows to detect typos ('bzrlin.') by making all valid test ids
2717
# appear prefixed ('bzrlib.' is "replaced" by 'bzrlib.').
2718
test_prefix_alias_registry.register('bzrlib', 'bzrlib')
2720
# Obvious higest levels prefixes, feel free to add your own via a plugin
2721
test_prefix_alias_registry.register('bd', 'bzrlib.doc')
2722
test_prefix_alias_registry.register('bu', 'bzrlib.utils')
2723
test_prefix_alias_registry.register('bt', 'bzrlib.tests')
2724
test_prefix_alias_registry.register('bb', 'bzrlib.tests.blackbox')
2725
test_prefix_alias_registry.register('bp', 'bzrlib.plugins')
2674
2728
def test_suite(keep_only=None, starting_with=None):
2675
2729
"""Build and return TestSuite for the whole of bzrlib.
2838
2892
loader = TestUtil.TestLoader()
2840
2894
if starting_with is not None:
2895
starting_with = test_prefix_alias_registry.resolve_alias(starting_with)
2841
2896
# We take precedence over keep_only because *at loading time* using
2842
2897
# both options means we will load less tests for the same final result.
2843
2898
def interesting_module(name):