25
26
class BashCompletionMixin(object):
26
27
"""Component for testing execution of a bash completion script."""
28
_test_needs_features = [tests.features.bash_feature]
29
_test_needs_features = [features.bash_feature]
30
31
def complete(self, words, cword=-1):
31
32
"""Perform a bash completion.
163
164
return s.replace("$(bzr ", "$('%s' " % self.get_bzr_path())
165
166
def test_revspec_tag_all(self):
166
self.requireFeature(tests.features.sed_feature)
167
self.requireFeature(features.sed_feature)
167
168
wt = self.make_branch_and_tree('.', format='dirstate-tags')
168
169
wt.branch.tags.set_tag('tag1', 'null:')
169
170
wt.branch.tags.set_tag('tag2', 'null:')
172
173
self.assertCompletionEquals('tag1', 'tag2', '3tag')
174
175
def test_revspec_tag_prefix(self):
175
self.requireFeature(tests.features.sed_feature)
176
self.requireFeature(features.sed_feature)
176
177
wt = self.make_branch_and_tree('.', format='dirstate-tags')
177
178
wt.branch.tags.set_tag('tag1', 'null:')
178
179
wt.branch.tags.set_tag('tag2', 'null:')
180
181
self.complete(['bzr', 'log', '-r', 'tag', ':', 't'])
181
182
self.assertCompletionEquals('tag1', 'tag2')
184
def test_revspec_tag_spaces(self):
185
self.requireFeature(features.sed_feature)
186
wt = self.make_branch_and_tree('.', format='dirstate-tags')
187
wt.branch.tags.set_tag('tag with spaces', 'null:')
188
self.complete(['bzr', 'log', '-r', 'tag', ':', 't'])
189
self.assertCompletionEquals(r'tag\ with\ spaces')
190
self.complete(['bzr', 'log', '-r', '"tag:t'])
191
self.assertCompletionEquals('tag:tag with spaces')
192
self.complete(['bzr', 'log', '-r', "'tag:t"])
193
self.assertCompletionEquals('tag:tag with spaces')
195
def test_revspec_tag_endrange(self):
196
self.requireFeature(features.sed_feature)
197
wt = self.make_branch_and_tree('.', format='dirstate-tags')
198
wt.branch.tags.set_tag('tag1', 'null:')
199
wt.branch.tags.set_tag('tag2', 'null:')
200
self.complete(['bzr', 'log', '-r', '3..tag', ':', 't'])
201
self.assertCompletionEquals('tag1', 'tag2')
202
self.complete(['bzr', 'log', '-r', '"3..tag:t'])
203
self.assertCompletionEquals('3..tag:tag1', '3..tag:tag2')
204
self.complete(['bzr', 'log', '-r', "'3..tag:t"])
205
self.assertCompletionEquals('3..tag:tag1', '3..tag:tag2')
184
208
class TestBashCodeGen(tests.TestCase):
249
273
\t\t# plugin "plugger 1.0"
250
274
\t\t# Some error message
251
\t\tcmdOpts='--bar=that --bar=this --foo'
275
\t\tcmdOpts=( --bar=that --bar=this --foo )
252
276
\t\tcase $curOpt in
253
\t\t\t--bar) optEnums='that this' ;;
277
\t\t\t--bar) optEnums=( that this ) ;;
256
280
''', cg.command_case(cmd))
274
298
self.assertSubset(['init', 'init-repo', 'init-repository'],
275
299
dc.data.all_command_aliases())
301
def test_commands_from_plugins(self):
304
self.assertSubset(['bash-completion'],
305
dc.data.all_command_aliases())
277
307
def test_commit_dashm(self):
278
308
dc = DataCollector()
279
309
cmd = dc.command('commit')