~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-11-22 21:54:24 UTC
  • mfrom: (5546.1.1 remove-old-dev-formats)
  • Revision ID: pqm@pqm.ubuntu.com-20101122215424-tfww6o1rayiyq1m7
(spiv) Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. (Andrew
 Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    commands,
20
20
    osutils,
21
21
    tests,
 
22
    trace,
22
23
    ui,
23
24
    )
24
25
from bzrlib.tests import script
160
161
class TestExecution(script.TestCaseWithTransportAndScript):
161
162
 
162
163
    def test_unknown_command(self):
163
 
        self.assertRaises(SyntaxError, self.run_script, 'foo')
 
164
        """A clear error is reported for commands that aren't recognised
 
165
 
 
166
        Testing the attributes of the SyntaxError instance is equivalent to
 
167
        using traceback.format_exception_only and comparing with:
 
168
          File "<string>", line 1
 
169
            foo --frob
 
170
            ^
 
171
        SyntaxError: Command not found "foo"
 
172
        """
 
173
        e = self.assertRaises(SyntaxError, self.run_script, "$ foo --frob")
 
174
        self.assertContainsRe(e.msg, "not found.*foo")
 
175
        self.assertEquals(e.text, "foo --frob")
 
176
 
 
177
    def test_blank_output_mismatches_output(self):
 
178
        """If you give output, the output must actually be blank.
 
179
        
 
180
        See <https://bugs.launchpad.net/bzr/+bug/637830>: previously blank
 
181
        output was a wildcard.  Now you must say ... if you want that.
 
182
        """
 
183
        self.assertRaises(AssertionError,
 
184
            self.run_script,
 
185
            """
 
186
            $ echo foo
 
187
            """)
 
188
 
 
189
    def test_null_output_matches_option(self):
 
190
        """If you want null output to be a wild card, you can pass 
 
191
        null_output_matches_anything to run_script"""
 
192
        self.run_script(
 
193
            """
 
194
            $ echo foo
 
195
            """, null_output_matches_anything=True)
 
196
 
 
197
    def test_ellipsis_everything(self):
 
198
        """A simple ellipsis matches everything."""
 
199
        self.run_script("""
 
200
        $ echo foo
 
201
        ...
 
202
        """)
 
203
 
 
204
    def test_ellipsis_matches_empty(self):
 
205
        self.run_script("""
 
206
        $ cd .
 
207
        ...
 
208
        """)
164
209
 
165
210
    def test_stops_on_unexpected_output(self):
166
211
        story = """
170
215
"""
171
216
        self.assertRaises(AssertionError, self.run_script, story)
172
217
 
173
 
 
174
218
    def test_stops_on_unexpected_error(self):
175
219
        story = """
176
220
$ cat
190
234
        # The status matters, not the output
191
235
        story = """
192
236
$ bzr init
 
237
...
193
238
$ cat >file
194
239
<Hello
195
240
$ bzr add file
 
241
...
196
242
$ bzr commit -m 'adding file'
 
243
2>...
197
244
"""
198
245
        self.run_script(story)
199
246
 
245
292
cat dog "chicken" 'dragon'
246
293
""")
247
294
 
 
295
    def test_verbosity_isolated(self):
 
296
        """Global verbosity is isolated from commands run in scripts.
 
297
        """
 
298
        # see also 656694; we should get rid of global verbosity
 
299
        self.run_script("""
 
300
        $ bzr init --quiet a
 
301
        """)
 
302
        self.assertEquals(trace.is_quiet(), False)
 
303
 
248
304
 
249
305
class TestCat(script.TestCaseWithTransportAndScript):
250
306
 
356
412
class TestBzr(script.TestCaseWithTransportAndScript):
357
413
 
358
414
    def test_bzr_smoke(self):
359
 
        self.run_script('$ bzr init branch')
 
415
        self.run_script("""
 
416
            $ bzr init branch
 
417
            Created a standalone tree (format: ...)
 
418
            """)
360
419
        self.failUnlessExists('branch')
361
420
 
362
421