/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 bzrlib/tests/test_script.py

  • Committer: Gary van der Merwe
  • Date: 2010-07-05 14:16:45 UTC
  • mto: This revision was merged to the branch mainline in revision 5338.
  • Revision ID: garyvdm@gmail.com-20100705141645-go944vdygnh0h1fh
Use includes rather than packages for PyQt modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010, 2011, 2016 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
from breezy import (
19
 
    commands,
 
18
from bzrlib import (
20
19
    osutils,
21
20
    tests,
22
 
    trace,
23
 
    ui,
24
21
    )
25
 
from breezy.tests import script
 
22
from bzrlib.tests import script
26
23
 
27
24
 
28
25
class TestSyntax(tests.TestCase):
29
26
 
30
27
    def test_comment_is_ignored(self):
31
 
        self.assertEqual([], script._script_to_commands('#comment\n'))
32
 
 
33
 
    def test_comment_multiple_lines(self):
34
 
        self.assertEqual([
35
 
            (['bar'], None, None, None),
36
 
            ],
37
 
            script._script_to_commands("""
38
 
            # this comment is ignored
39
 
            # so is this
40
 
            # no we run bar
41
 
            $ bar
42
 
            """))
43
 
 
44
 
    def test_trim_blank_lines(self):
45
 
        """Blank lines are respected, but trimmed at the start and end.
46
 
 
47
 
        Python triple-quoted syntax is going to give stubby/empty blank lines
48
 
        right at the start and the end.  These are cut off so that callers don't
49
 
        need special syntax to avoid them.
50
 
 
51
 
        However we do want to be able to match commands that emit blank lines.
52
 
        """
53
 
        self.assertEqual([
54
 
            (['bar'], None, '\n', None),
55
 
            ],
56
 
            script._script_to_commands("""
57
 
            $bar
58
 
 
59
 
            """))
 
28
        self.assertEquals([], script._script_to_commands('#comment\n'))
 
29
 
 
30
    def test_empty_line_is_ignored(self):
 
31
        self.assertEquals([], script._script_to_commands('\n'))
60
32
 
61
33
    def test_simple_command(self):
62
 
        self.assertEqual([(['cd', 'trunk'], None, None, None)],
63
 
                         script._script_to_commands('$ cd trunk'))
 
34
        self.assertEquals([(['cd', 'trunk'], None, None, None)],
 
35
                           script._script_to_commands('$ cd trunk'))
64
36
 
65
37
    def test_command_with_single_quoted_param(self):
66
 
        story = """$ brz commit -m 'two words'"""
67
 
        self.assertEqual([(['brz', 'commit', '-m', "'two words'"],
68
 
                           None, None, None)],
69
 
                         script._script_to_commands(story))
 
38
        story = """$ bzr commit -m 'two words'"""
 
39
        self.assertEquals([(['bzr', 'commit', '-m', "'two words'"],
 
40
                            None, None, None)],
 
41
                           script._script_to_commands(story))
70
42
 
71
43
    def test_command_with_double_quoted_param(self):
72
 
        story = """$ brz commit -m "two words" """
73
 
        self.assertEqual([(['brz', 'commit', '-m', '"two words"'],
74
 
                           None, None, None)],
75
 
                         script._script_to_commands(story))
 
44
        story = """$ bzr commit -m "two words" """
 
45
        self.assertEquals([(['bzr', 'commit', '-m', '"two words"'],
 
46
                            None, None, None)],
 
47
                           script._script_to_commands(story))
76
48
 
77
49
    def test_command_with_input(self):
78
 
        self.assertEqual(
 
50
        self.assertEquals(
79
51
            [(['cat', '>file'], 'content\n', None, None)],
80
52
            script._script_to_commands('$ cat >file\n<content\n'))
81
53
 
83
55
        # scripts are commonly given indented within the test source code, and
84
56
        # common indentation is stripped off
85
57
        story = """
86
 
            $ brz add
 
58
            $ bzr add
87
59
            adding file
88
60
            adding file2
89
61
            """
90
 
        self.assertEqual([(['brz', 'add'], None,
91
 
                           'adding file\nadding file2\n', None)],
92
 
                         script._script_to_commands(story))
 
62
        self.assertEquals([(['bzr', 'add'], None,
 
63
                            'adding file\nadding file2\n', None)],
 
64
                          script._script_to_commands(story))
93
65
 
94
66
    def test_command_with_output(self):
95
67
        story = """
96
 
$ brz add
 
68
$ bzr add
97
69
adding file
98
70
adding file2
99
71
"""
100
 
        self.assertEqual([(['brz', 'add'], None,
101
 
                           'adding file\nadding file2\n', None)],
102
 
                         script._script_to_commands(story))
 
72
        self.assertEquals([(['bzr', 'add'], None,
 
73
                            'adding file\nadding file2\n', None)],
 
74
                          script._script_to_commands(story))
103
75
 
104
76
    def test_command_with_error(self):
105
77
        story = """
106
 
$ brz branch foo
107
 
2>brz: ERROR: Not a branch: "foo"
 
78
$ bzr branch foo
 
79
2>bzr: ERROR: Not a branch: "foo"
108
80
"""
109
 
        self.assertEqual([(['brz', 'branch', 'foo'],
110
 
                           None, None, 'brz: ERROR: Not a branch: "foo"\n')],
111
 
                         script._script_to_commands(story))
 
81
        self.assertEquals([(['bzr', 'branch', 'foo'],
 
82
                            None, None, 'bzr: ERROR: Not a branch: "foo"\n')],
 
83
                          script._script_to_commands(story))
112
84
 
113
85
    def test_input_without_command(self):
114
86
        self.assertRaises(SyntaxError, script._script_to_commands, '<input')
118
90
 
119
91
    def test_command_with_backquotes(self):
120
92
        story = """
121
 
$ foo = `brz file-id toto`
 
93
$ foo = `bzr file-id toto`
122
94
"""
123
 
        self.assertEqual([(['foo', '=', '`brz file-id toto`'],
124
 
                           None, None, None)],
125
 
                         script._script_to_commands(story))
 
95
        self.assertEquals([(['foo', '=', '`bzr file-id toto`'],
 
96
                            None, None, None)],
 
97
                          script._script_to_commands(story))
126
98
 
127
99
 
128
100
class TestRedirections(tests.TestCase):
143
115
        self._check('foo', None, None, ['bar', 'baz'], ['bar', '<foo', 'baz'])
144
116
 
145
117
    def test_output_redirection(self):
146
 
        self._check(None, 'foo', 'w+', [], ['>foo'])
147
 
        self._check(None, 'foo', 'w+', ['bar'], ['bar', '>foo'])
148
 
        self._check(None, 'foo', 'w+', ['bar'], ['bar', '>', 'foo'])
149
 
        self._check(None, 'foo', 'a+', [], ['>>foo'])
150
 
        self._check(None, 'foo', 'a+', ['bar'], ['bar', '>>foo'])
151
 
        self._check(None, 'foo', 'a+', ['bar'], ['bar', '>>', 'foo'])
 
118
        self._check(None, 'foo', 'wb+', [], ['>foo'])
 
119
        self._check(None, 'foo', 'wb+', ['bar'], ['bar', '>foo'])
 
120
        self._check(None, 'foo', 'wb+', ['bar'], ['bar', '>', 'foo'])
 
121
        self._check(None, 'foo', 'ab+', [], ['>>foo'])
 
122
        self._check(None, 'foo', 'ab+', ['bar'], ['bar', '>>foo'])
 
123
        self._check(None, 'foo', 'ab+', ['bar'], ['bar', '>>', 'foo'])
152
124
 
153
125
    def test_redirection_syntax_errors(self):
154
126
        self._check('', None, None, [], ['<'])
155
 
        self._check(None, '', 'w+', [], ['>'])
156
 
        self._check(None, '', 'a+', [], ['>>'])
157
 
        self._check('>', '', 'a+', [], ['<', '>', '>>'])
 
127
        self._check(None, '', 'wb+', [], ['>'])
 
128
        self._check(None, '', 'ab+', [], ['>>'])
 
129
        self._check('>', '', 'ab+', [], ['<', '>', '>>'])
 
130
 
158
131
 
159
132
 
160
133
class TestExecution(script.TestCaseWithTransportAndScript):
161
134
 
162
135
    def test_unknown_command(self):
163
 
        """A clear error is reported for commands that aren't recognised
164
 
 
165
 
        Testing the attributes of the SyntaxError instance is equivalent to
166
 
        using traceback.format_exception_only and comparing with:
167
 
          File "<string>", line 1
168
 
            foo --frob
169
 
            ^
170
 
        SyntaxError: Command not found "foo"
171
 
        """
172
 
        e = self.assertRaises(SyntaxError, self.run_script, "$ foo --frob")
173
 
        self.assertContainsRe(e.msg, "not found.*foo")
174
 
        self.assertEqual(e.text, "foo --frob")
175
 
 
176
 
    def test_blank_output_mismatches_output(self):
177
 
        """If you give output, the output must actually be blank.
178
 
 
179
 
        See <https://bugs.launchpad.net/bzr/+bug/637830>: previously blank
180
 
        output was a wildcard.  Now you must say ... if you want that.
181
 
        """
182
 
        self.assertRaises(AssertionError,
183
 
                          self.run_script,
184
 
                          """
185
 
            $ echo foo
186
 
            """)
187
 
 
188
 
    def test_null_output_matches_option(self):
189
 
        """If you want null output to be a wild card, you can pass
190
 
        null_output_matches_anything to run_script"""
191
 
        self.run_script(
192
 
            """
193
 
            $ echo foo
194
 
            """, null_output_matches_anything=True)
195
 
 
196
 
    def test_ellipsis_everything(self):
197
 
        """A simple ellipsis matches everything."""
198
 
        self.run_script("""
199
 
        $ echo foo
200
 
        ...
201
 
        """)
202
 
 
203
 
    def test_ellipsis_matches_empty(self):
204
 
        self.run_script("""
205
 
        $ cd .
206
 
        ...
207
 
        """)
 
136
        self.assertRaises(SyntaxError, self.run_script, 'foo')
208
137
 
209
138
    def test_stops_on_unexpected_output(self):
210
139
        story = """
214
143
"""
215
144
        self.assertRaises(AssertionError, self.run_script, story)
216
145
 
 
146
 
217
147
    def test_stops_on_unexpected_error(self):
218
148
        story = """
219
149
$ cat
220
150
<Hello
221
 
$ brz not-a-command
 
151
$ bzr not-a-command
222
152
"""
223
153
        self.assertRaises(AssertionError, self.run_script, story)
224
154
 
225
155
    def test_continue_on_expected_error(self):
226
156
        story = """
227
 
$ brz not-a-command
 
157
$ bzr not-a-command
228
158
2>..."not-a-command"
229
159
"""
230
160
        self.run_script(story)
232
162
    def test_continue_on_error_output(self):
233
163
        # The status matters, not the output
234
164
        story = """
235
 
$ brz init
236
 
...
 
165
$ bzr init
237
166
$ cat >file
238
167
<Hello
239
 
$ brz add file
240
 
...
241
 
$ brz commit -m 'adding file'
242
 
2>...
 
168
$ bzr add file
 
169
$ bzr commit -m 'adding file'
243
170
"""
244
171
        self.run_script(story)
245
172
 
255
182
"""
256
183
        self.run_script(story)
257
184
        story = """
258
 
$ brz not-a-command
 
185
$ bzr not-a-command
259
186
2>..."not-a-command"
260
187
"""
261
188
        self.run_script(story)
262
189
 
263
190
        story = """
264
 
$ brz branch not-a-branch
265
 
2>brz: ERROR: Not a branch...not-a-branch/".
 
191
$ bzr branch not-a-branch
 
192
2>bzr: ERROR: Not a branch...not-a-branch/".
266
193
"""
267
194
        self.run_script(story)
268
195
 
291
218
cat dog "chicken" 'dragon'
292
219
""")
293
220
 
294
 
    def test_verbosity_isolated(self):
295
 
        """Global verbosity is isolated from commands run in scripts.
296
 
        """
297
 
        # see also 656694; we should get rid of global verbosity
298
 
        self.run_script("""
299
 
        $ brz init --quiet a
300
 
        """)
301
 
        self.assertEqual(trace.is_quiet(), False)
302
 
 
303
221
 
304
222
class TestCat(script.TestCaseWithTransportAndScript):
305
223
 
309
227
    def test_cat_input_to_output(self):
310
228
        retcode, out, err = self.run_command(['cat'],
311
229
                                             'content\n', 'content\n', None)
312
 
        self.assertEqual('content\n', out)
313
 
        self.assertEqual(None, err)
 
230
        self.assertEquals('content\n', out)
 
231
        self.assertEquals(None, err)
314
232
 
315
233
    def test_cat_file_to_output(self):
316
 
        self.build_tree_contents([('file', b'content\n')])
 
234
        self.build_tree_contents([('file', 'content\n')])
317
235
        retcode, out, err = self.run_command(['cat', 'file'],
318
236
                                             None, 'content\n', None)
319
 
        self.assertEqual('content\n', out)
320
 
        self.assertEqual(None, err)
 
237
        self.assertEquals('content\n', out)
 
238
        self.assertEquals(None, err)
321
239
 
322
240
    def test_cat_input_to_file(self):
323
241
        retcode, out, err = self.run_command(['cat', '>file'],
324
242
                                             'content\n', None, None)
325
243
        self.assertFileEqual('content\n', 'file')
326
 
        self.assertEqual(None, out)
327
 
        self.assertEqual(None, err)
 
244
        self.assertEquals(None, out)
 
245
        self.assertEquals(None, err)
328
246
        retcode, out, err = self.run_command(['cat', '>>file'],
329
247
                                             'more\n', None, None)
330
248
        self.assertFileEqual('content\nmore\n', 'file')
331
 
        self.assertEqual(None, out)
332
 
        self.assertEqual(None, err)
 
249
        self.assertEquals(None, out)
 
250
        self.assertEquals(None, err)
333
251
 
334
252
    def test_cat_file_to_file(self):
335
 
        self.build_tree_contents([('file', b'content\n')])
 
253
        self.build_tree_contents([('file', 'content\n')])
336
254
        retcode, out, err = self.run_command(['cat', 'file', '>file2'],
337
255
                                             None, None, None)
338
 
        self.assertFileEqual(b'content\n', 'file2')
 
256
        self.assertFileEqual('content\n', 'file2')
339
257
 
340
258
    def test_cat_files_to_file(self):
341
 
        self.build_tree_contents([('cat', b'cat\n')])
342
 
        self.build_tree_contents([('dog', b'dog\n')])
 
259
        self.build_tree_contents([('cat', 'cat\n')])
 
260
        self.build_tree_contents([('dog', 'dog\n')])
343
261
        retcode, out, err = self.run_command(['cat', 'cat', 'dog', '>file'],
344
262
                                             None, None, None)
345
 
        self.assertFileEqual(b'cat\ndog\n', 'file')
 
263
        self.assertFileEqual('cat\ndog\n', 'file')
346
264
 
347
265
    def test_cat_bogus_input_file(self):
348
266
        self.run_script("""
373
291
 
374
292
    def test_mkdir_jailed(self):
375
293
        self.assertRaises(ValueError, self.run_script, '$ mkdir /out-of-jail')
376
 
        self.assertRaises(ValueError, self.run_script,
377
 
                          '$ mkdir ../out-of-jail')
 
294
        self.assertRaises(ValueError, self.run_script, '$ mkdir ../out-of-jail')
378
295
 
379
296
    def test_mkdir_in_jail(self):
380
297
        self.run_script("""
383
300
$ mkdir ../dir2
384
301
$ cd ..
385
302
""")
386
 
        self.assertPathExists('dir')
387
 
        self.assertPathExists('dir2')
 
303
        self.failUnlessExists('dir')
 
304
        self.failUnlessExists('dir2')
388
305
 
389
306
 
390
307
class TestCd(script.TestCaseWithTransportAndScript):
397
314
        self.assertRaises(ValueError, self.run_script, '$ cd ..')
398
315
 
399
316
    def test_cd_dir_and_back_home(self):
400
 
        self.assertEqual(self.test_dir, osutils.getcwd())
 
317
        self.assertEquals(self.test_dir, osutils.getcwd())
401
318
        self.run_script("""
402
319
$ mkdir dir
403
320
$ cd dir
404
321
""")
405
 
        self.assertEqual(osutils.pathjoin(self.test_dir, 'dir'),
406
 
                         osutils.getcwd())
 
322
        self.assertEquals(osutils.pathjoin(self.test_dir, 'dir'),
 
323
                          osutils.getcwd())
407
324
 
408
325
        self.run_script('$ cd')
409
 
        self.assertEqual(self.test_dir, osutils.getcwd())
410
 
 
411
 
 
412
 
class TestBrz(script.TestCaseWithTransportAndScript):
413
 
 
414
 
    def test_brz_smoke(self):
415
 
        self.run_script("""
416
 
            $ brz init branch
417
 
            Created a standalone tree (format: ...)
418
 
            """)
419
 
        self.assertPathExists('branch')
 
326
        self.assertEquals(self.test_dir, osutils.getcwd())
 
327
 
 
328
 
 
329
class TestBzr(script.TestCaseWithTransportAndScript):
 
330
 
 
331
    def test_bzr_smoke(self):
 
332
        self.run_script('$ bzr init branch')
 
333
        self.failUnlessExists('branch')
420
334
 
421
335
 
422
336
class TestEcho(script.TestCaseWithMemoryTransportAndScript):
435
349
 
436
350
    def test_echo_to_output(self):
437
351
        retcode, out, err = self.run_command(['echo'], None, '\n', None)
438
 
        self.assertEqual('\n', out)
439
 
        self.assertEqual(None, err)
 
352
        self.assertEquals('\n', out)
 
353
        self.assertEquals(None, err)
440
354
 
441
355
    def test_echo_some_to_output(self):
442
356
        retcode, out, err = self.run_command(['echo', 'hello'],
443
357
                                             None, 'hello\n', None)
444
 
        self.assertEqual('hello\n', out)
445
 
        self.assertEqual(None, err)
 
358
        self.assertEquals('hello\n', out)
 
359
        self.assertEquals(None, err)
446
360
 
447
361
    def test_echo_more_output(self):
448
362
        retcode, out, err = self.run_command(
449
363
            ['echo', 'hello', 'happy', 'world'],
450
364
            None, 'hello happy world\n', None)
451
 
        self.assertEqual('hello happy world\n', out)
452
 
        self.assertEqual(None, err)
 
365
        self.assertEquals('hello happy world\n', out)
 
366
        self.assertEquals(None, err)
453
367
 
454
368
    def test_echo_appended(self):
455
369
        retcode, out, err = self.run_command(['echo', 'hello', '>file'],
456
370
                                             None, None, None)
457
 
        self.assertEqual(None, out)
458
 
        self.assertEqual(None, err)
459
 
        self.assertFileEqual(b'hello\n', 'file')
 
371
        self.assertEquals(None, out)
 
372
        self.assertEquals(None, err)
 
373
        self.assertFileEqual('hello\n', 'file')
460
374
        retcode, out, err = self.run_command(['echo', 'happy', '>>file'],
461
375
                                             None, None, None)
462
 
        self.assertEqual(None, out)
463
 
        self.assertEqual(None, err)
464
 
        self.assertFileEqual(b'hello\nhappy\n', 'file')
465
 
 
466
 
    def test_empty_line_in_output_is_respected(self):
467
 
        self.run_script("""
468
 
            $ echo
469
 
 
470
 
            $ echo bar
471
 
            bar
472
 
            """)
 
376
        self.assertEquals(None, out)
 
377
        self.assertEquals(None, err)
 
378
        self.assertFileEqual('hello\nhappy\n', 'file')
473
379
 
474
380
 
475
381
class TestRm(script.TestCaseWithTransportAndScript):
480
386
 
481
387
    def test_rm_file(self):
482
388
        self.run_script('$ echo content >file')
483
 
        self.assertPathExists('file')
 
389
        self.failUnlessExists('file')
484
390
        self.run_script('$ rm file')
485
 
        self.assertPathDoesNotExist('file')
 
391
        self.failIfExists('file')
486
392
 
487
393
    def test_rm_file_force(self):
488
 
        self.assertPathDoesNotExist('file')
 
394
        self.failIfExists('file')
489
395
        self.run_script('$ rm -f file')
490
 
        self.assertPathDoesNotExist('file')
 
396
        self.failIfExists('file')
491
397
 
492
398
    def test_rm_files(self):
493
399
        self.run_script("""
494
400
$ echo content >file
495
401
$ echo content >file2
496
402
""")
497
 
        self.assertPathExists('file2')
 
403
        self.failUnlessExists('file2')
498
404
        self.run_script('$ rm file file2')
499
 
        self.assertPathDoesNotExist('file2')
 
405
        self.failIfExists('file2')
500
406
 
501
407
    def test_rm_dir(self):
502
408
        self.run_script('$ mkdir dir')
503
 
        self.assertPathExists('dir')
 
409
        self.failUnlessExists('dir')
504
410
        self.run_script("""
505
411
$ rm dir
506
412
2>rm: cannot remove 'dir': Is a directory
507
413
""")
508
 
        self.assertPathExists('dir')
 
414
        self.failUnlessExists('dir')
509
415
 
510
416
    def test_rm_dir_recursive(self):
511
417
        self.run_script("""
512
418
$ mkdir dir
513
419
$ rm -r dir
514
420
""")
515
 
        self.assertPathDoesNotExist('dir')
 
421
        self.failIfExists('dir')
516
422
 
517
423
 
518
424
class TestMv(script.TestCaseWithTransportAndScript):
524
430
 
525
431
    def test_move_file(self):
526
432
        self.run_script('$ echo content >file')
527
 
        self.assertPathExists('file')
 
433
        self.failUnlessExists('file')
528
434
        self.run_script('$ mv file new_name')
529
 
        self.assertPathDoesNotExist('file')
530
 
        self.assertPathExists('new_name')
 
435
        self.failIfExists('file')
 
436
        self.failUnlessExists('new_name')
531
437
 
532
438
    def test_move_unknown_file(self):
533
439
        self.assertRaises(AssertionError,
539
445
$ echo content >dir/file
540
446
""")
541
447
        self.run_script('$ mv dir new_name')
542
 
        self.assertPathDoesNotExist('dir')
543
 
        self.assertPathExists('new_name')
544
 
        self.assertPathExists('new_name/file')
 
448
        self.failIfExists('dir')
 
449
        self.failUnlessExists('new_name')
 
450
        self.failUnlessExists('new_name/file')
545
451
 
546
452
    def test_move_file_into_dir(self):
547
453
        self.run_script("""
549
455
$ echo content > file
550
456
""")
551
457
        self.run_script('$ mv file dir')
552
 
        self.assertPathExists('dir')
553
 
        self.assertPathDoesNotExist('file')
554
 
        self.assertPathExists('dir/file')
555
 
 
556
 
 
557
 
class cmd_test_confirm(commands.Command):
558
 
 
559
 
    def run(self):
560
 
        if ui.ui_factory.get_boolean(
561
 
                u'Really do it',
562
 
                # 'breezy.tests.test_script.confirm',
563
 
                # {}
564
 
                ):
565
 
            self.outf.write('Do it!\n')
566
 
        else:
567
 
            print('ok, no')
568
 
 
569
 
 
570
 
class TestUserInteraction(script.TestCaseWithMemoryTransportAndScript):
571
 
 
572
 
    def test_confirm_action(self):
573
 
        """You can write tests that demonstrate user confirmation.
574
 
 
575
 
        Specifically, ScriptRunner does't care if the output line for the
576
 
        prompt isn't terminated by a newline from the program; it's implicitly
577
 
        terminated by the input.
578
 
        """
579
 
        commands.builtin_command_registry.register(cmd_test_confirm)
580
 
        self.addCleanup(
581
 
            commands.builtin_command_registry.remove, 'test-confirm')
582
 
        self.run_script("""
583
 
            $ brz test-confirm
584
 
            2>Really do it? ([y]es, [n]o): yes
585
 
            <y
586
 
            Do it!
587
 
            $ brz test-confirm
588
 
            2>Really do it? ([y]es, [n]o): no
589
 
            <n
590
 
            ok, no
591
 
            """)
592
 
 
593
 
 
594
 
class TestShelve(script.TestCaseWithTransportAndScript):
595
 
 
596
 
    def setUp(self):
597
 
        super(TestShelve, self).setUp()
598
 
        self.run_script("""
599
 
            $ brz init test
600
 
            Created a standalone tree (format: 2a)
601
 
            $ cd test
602
 
            $ echo foo > file
603
 
            $ brz add
604
 
            adding file
605
 
            $ brz commit -m 'file added'
606
 
            2>Committing to:...test/
607
 
            2>added file
608
 
            2>Committed revision 1.
609
 
            $ echo bar > file
610
 
            """)
611
 
 
612
 
    def test_shelve(self):
613
 
        self.run_script("""
614
 
            $ brz shelve -m 'shelve bar'
615
 
            2>Shelve? ([y]es, [N]o, [f]inish, [q]uit): yes
616
 
            <y
617
 
            2>Selected changes:
618
 
            2> M  file
619
 
            2>Shelve 1 change(s)? ([y]es, [N]o, [f]inish, [q]uit): yes
620
 
            <y
621
 
            2>Changes shelved with id "1".
622
 
            """,
623
 
                        null_output_matches_anything=True)
624
 
        self.run_script("""
625
 
            $ brz shelve --list
626
 
              1: shelve bar
627
 
            """)
628
 
 
629
 
    def test_dont_shelve(self):
630
 
        # We intentionally provide no input here to test EOF
631
 
        self.run_script((
632
 
            "$ brz shelve -m 'shelve bar'\n"
633
 
            "2>Shelve? ([y]es, [N]o, [f]inish, [q]uit): \n"
634
 
            "2>No changes to shelve.\n"
635
 
            ), null_output_matches_anything=True)
636
 
        self.run_script("""
637
 
            $ brz st
638
 
            modified:
639
 
              file
640
 
            """)
 
458
        self.failUnlessExists('dir')
 
459
        self.failIfExists('file')
 
460
        self.failUnlessExists('dir/file')
 
461