/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/bash_completion/tests/test_bashcomp.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import sys
18
18
 
19
 
import bzrlib
20
 
from bzrlib import commands, tests
21
 
from bzrlib.tests import features
22
 
from bzrlib.plugins.bash_completion.bashcomp import *
 
19
import breezy
 
20
from breezy import commands, tests
 
21
from breezy.tests import features
 
22
from breezy.plugins.bash_completion.bashcomp import *
23
23
 
24
24
import subprocess
25
25
 
49
49
        input += ('COMP_WORDS=( %s )\n' %
50
50
                  ' '.join(["'"+w.replace("'", "'\\''")+"'" for w in words]))
51
51
        input += 'COMP_CWORD=%d\n' % cword
52
 
        input += '%s\n' % getattr(self, 'script_name', '_bzr')
 
52
        input += '%s\n' % getattr(self, 'script_name', '_brz')
53
53
        input += 'echo ${#COMPREPLY[*]}\n'
54
54
        input += "IFS=$'\\n'\n"
55
55
        input += 'echo "${COMPREPLY[*]}"\n'
95
95
 
96
96
 
97
97
class TestBashCompletion(tests.TestCase, BashCompletionMixin):
98
 
    """Test bash completions that don't execute bzr."""
 
98
    """Test bash completions that don't execute brz."""
99
99
 
100
100
    def test_simple_scipt(self):
101
101
        """Ensure that the test harness works as expected"""
102
102
        self.script = """
103
 
_bzr() {
 
103
_brz() {
104
104
    COMPREPLY=()
105
105
    # add all words in reverse order, with some markup around them
106
106
    for ((i = ${#COMP_WORDS[@]}; i > 0; --i)); do
114
114
        self.assertCompletionEquals("-'baz+", '-"bar+', '-foo+', '+"bar-')
115
115
 
116
116
    def test_cmd_ini(self):
117
 
        self.complete(['bzr', 'ini'])
 
117
        self.complete(['brz', 'ini'])
118
118
        self.assertCompletionContains('init', 'init-repo', 'init-repository')
119
119
        self.assertCompletionOmits('commit')
120
120
 
121
121
    def test_init_opts(self):
122
 
        self.complete(['bzr', 'init', '-'])
 
122
        self.complete(['brz', 'init', '-'])
123
123
        self.assertCompletionContains('-h', '--2a', '--format=2a')
124
124
 
125
125
    def test_global_opts(self):
126
 
        self.complete(['bzr', '-', 'init'], cword=1)
 
126
        self.complete(['brz', '-', 'init'], cword=1)
127
127
        self.assertCompletionContains('--no-plugins', '--builtin')
128
128
 
129
129
    def test_commit_dashm(self):
130
 
        self.complete(['bzr', 'commit', '-m'])
 
130
        self.complete(['brz', 'commit', '-m'])
131
131
        self.assertCompletionEquals('-m')
132
132
 
133
133
    def test_status_negated(self):
134
 
        self.complete(['bzr', 'status', '--n'])
 
134
        self.complete(['brz', 'status', '--n'])
135
135
        self.assertCompletionContains('--no-versioned', '--no-verbose')
136
136
 
137
137
    def test_init_format_any(self):
138
 
        self.complete(['bzr', 'init', '--format', '=', 'directory'], cword=3)
 
138
        self.complete(['brz', 'init', '--format', '=', 'directory'], cword=3)
139
139
        self.assertCompletionContains('1.9', '2a')
140
140
 
141
141
    def test_init_format_2(self):
142
 
        self.complete(['bzr', 'init', '--format', '=', '2', 'directory'],
 
142
        self.complete(['brz', 'init', '--format', '=', '2', 'directory'],
143
143
                      cword=4)
144
144
        self.assertCompletionContains('2a')
145
145
        self.assertCompletionOmits('1.9')
147
147
 
148
148
class TestBashCompletionInvoking(tests.TestCaseWithTransport,
149
149
                                 BashCompletionMixin):
150
 
    """Test bash completions that might execute bzr.
 
150
    """Test bash completions that might execute brz.
151
151
 
152
 
    Only the syntax ``$(bzr ...`` is supported so far. The bzr command
153
 
    will be replaced by the bzr instance running this selftest.
 
152
    Only the syntax ``$(brz ...`` is supported so far. The brz command
 
153
    will be replaced by the brz instance running this selftest.
154
154
    """
155
155
 
156
156
    def setUp(self):
161
161
 
162
162
    def get_script(self):
163
163
        s = super(TestBashCompletionInvoking, self).get_script()
164
 
        return s.replace("$(bzr ", "$('%s' " % self.get_bzr_path())
 
164
        return s.replace("$(brz ", "$('%s' " % self.get_brz_path())
165
165
 
166
166
    def test_revspec_tag_all(self):
167
167
        self.requireFeature(features.sed_feature)
169
169
        wt.branch.tags.set_tag('tag1', 'null:')
170
170
        wt.branch.tags.set_tag('tag2', 'null:')
171
171
        wt.branch.tags.set_tag('3tag', 'null:')
172
 
        self.complete(['bzr', 'log', '-r', 'tag', ':'])
 
172
        self.complete(['brz', 'log', '-r', 'tag', ':'])
173
173
        self.assertCompletionEquals('tag1', 'tag2', '3tag')
174
174
 
175
175
    def test_revspec_tag_prefix(self):
178
178
        wt.branch.tags.set_tag('tag1', 'null:')
179
179
        wt.branch.tags.set_tag('tag2', 'null:')
180
180
        wt.branch.tags.set_tag('3tag', 'null:')
181
 
        self.complete(['bzr', 'log', '-r', 'tag', ':', 't'])
 
181
        self.complete(['brz', 'log', '-r', 'tag', ':', 't'])
182
182
        self.assertCompletionEquals('tag1', 'tag2')
183
183
 
184
184
    def test_revspec_tag_spaces(self):
185
185
        self.requireFeature(features.sed_feature)
186
186
        wt = self.make_branch_and_tree('.', format='dirstate-tags')
187
187
        wt.branch.tags.set_tag('tag with spaces', 'null:')
188
 
        self.complete(['bzr', 'log', '-r', 'tag', ':', 't'])
 
188
        self.complete(['brz', 'log', '-r', 'tag', ':', 't'])
189
189
        self.assertCompletionEquals(r'tag\ with\ spaces')
190
 
        self.complete(['bzr', 'log', '-r', '"tag:t'])
 
190
        self.complete(['brz', 'log', '-r', '"tag:t'])
191
191
        self.assertCompletionEquals('tag:tag with spaces')
192
 
        self.complete(['bzr', 'log', '-r', "'tag:t"])
 
192
        self.complete(['brz', 'log', '-r', "'tag:t"])
193
193
        self.assertCompletionEquals('tag:tag with spaces')
194
194
 
195
195
    def test_revspec_tag_endrange(self):
197
197
        wt = self.make_branch_and_tree('.', format='dirstate-tags')
198
198
        wt.branch.tags.set_tag('tag1', 'null:')
199
199
        wt.branch.tags.set_tag('tag2', 'null:')
200
 
        self.complete(['bzr', 'log', '-r', '3..tag', ':', 't'])
 
200
        self.complete(['brz', 'log', '-r', '3..tag', ':', 't'])
201
201
        self.assertCompletionEquals('tag1', 'tag2')
202
 
        self.complete(['bzr', 'log', '-r', '"3..tag:t'])
 
202
        self.complete(['brz', 'log', '-r', '"3..tag:t'])
203
203
        self.assertCompletionEquals('3..tag:tag1', '3..tag:tag2')
204
 
        self.complete(['bzr', 'log', '-r', "'3..tag:t"])
 
204
        self.complete(['brz', 'log', '-r', "'3..tag:t"])
205
205
        self.assertCompletionEquals('3..tag:tag1', '3..tag:tag2')
206
206
 
207
207
 
221
221
        self.assertEqual('', BashCodeGen(data, debug=False).debug_output())
222
222
        self.assertTrue(BashCodeGen(data, debug=True).debug_output())
223
223
 
224
 
    def test_bzr_version(self):
 
224
    def test_brz_version(self):
225
225
        data = CompletionData()
226
226
        cg = BashCodeGen(data)
227
 
        self.assertEqual('%s.' % bzrlib.version_string, cg.bzr_version())
 
227
        self.assertEqual('%s.' % breezy.version_string, cg.brz_version())
228
228
        data.plugins['foo'] = PluginData('foo', '1.0')
229
229
        data.plugins['bar'] = PluginData('bar', '2.0')
230
230
        cg = BashCodeGen(data)
231
231
        self.assertEqual('''\
232
232
%s and the following plugins:
233
233
# bar 2.0
234
 
# foo 1.0''' % bzrlib.version_string, cg.bzr_version())
 
234
# foo 1.0''' % breezy.version_string, cg.brz_version())
235
235
 
236
236
    def test_global_options(self):
237
237
        data = CompletionData()