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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 18:06:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521180619-5qoo0470asgdnljt
Fix more tests (all?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
                           script._script_to_commands('$ cd trunk'))
64
64
 
65
65
    def test_command_with_single_quoted_param(self):
66
 
        story = """$ bzr commit -m 'two words'"""
67
 
        self.assertEqual([(['bzr', 'commit', '-m', "'two words'"],
 
66
        story = """$ brz commit -m 'two words'"""
 
67
        self.assertEqual([(['brz', 'commit', '-m', "'two words'"],
68
68
                            None, None, None)],
69
69
                           script._script_to_commands(story))
70
70
 
71
71
    def test_command_with_double_quoted_param(self):
72
 
        story = """$ bzr commit -m "two words" """
73
 
        self.assertEqual([(['bzr', 'commit', '-m', '"two words"'],
 
72
        story = """$ brz commit -m "two words" """
 
73
        self.assertEqual([(['brz', 'commit', '-m', '"two words"'],
74
74
                            None, None, None)],
75
75
                           script._script_to_commands(story))
76
76
 
83
83
        # scripts are commonly given indented within the test source code, and
84
84
        # common indentation is stripped off
85
85
        story = """
86
 
            $ bzr add
 
86
            $ brz add
87
87
            adding file
88
88
            adding file2
89
89
            """
90
 
        self.assertEqual([(['bzr', 'add'], None,
 
90
        self.assertEqual([(['brz', 'add'], None,
91
91
                            'adding file\nadding file2\n', None)],
92
92
                          script._script_to_commands(story))
93
93
 
94
94
    def test_command_with_output(self):
95
95
        story = """
96
 
$ bzr add
 
96
$ brz add
97
97
adding file
98
98
adding file2
99
99
"""
100
 
        self.assertEqual([(['bzr', 'add'], None,
 
100
        self.assertEqual([(['brz', 'add'], None,
101
101
                            'adding file\nadding file2\n', None)],
102
102
                          script._script_to_commands(story))
103
103
 
104
104
    def test_command_with_error(self):
105
105
        story = """
106
 
$ bzr branch foo
107
 
2>bzr: ERROR: Not a branch: "foo"
 
106
$ brz branch foo
 
107
2>brz: ERROR: Not a branch: "foo"
108
108
"""
109
 
        self.assertEqual([(['bzr', 'branch', 'foo'],
110
 
                            None, None, 'bzr: ERROR: Not a branch: "foo"\n')],
 
109
        self.assertEqual([(['brz', 'branch', 'foo'],
 
110
                            None, None, 'brz: ERROR: Not a branch: "foo"\n')],
111
111
                          script._script_to_commands(story))
112
112
 
113
113
    def test_input_without_command(self):
118
118
 
119
119
    def test_command_with_backquotes(self):
120
120
        story = """
121
 
$ foo = `bzr file-id toto`
 
121
$ foo = `brz file-id toto`
122
122
"""
123
 
        self.assertEqual([(['foo', '=', '`bzr file-id toto`'],
 
123
        self.assertEqual([(['foo', '=', '`brz file-id toto`'],
124
124
                            None, None, None)],
125
125
                          script._script_to_commands(story))
126
126
 
219
219
        story = """
220
220
$ cat
221
221
<Hello
222
 
$ bzr not-a-command
 
222
$ brz not-a-command
223
223
"""
224
224
        self.assertRaises(AssertionError, self.run_script, story)
225
225
 
226
226
    def test_continue_on_expected_error(self):
227
227
        story = """
228
 
$ bzr not-a-command
 
228
$ brz not-a-command
229
229
2>..."not-a-command"
230
230
"""
231
231
        self.run_script(story)
233
233
    def test_continue_on_error_output(self):
234
234
        # The status matters, not the output
235
235
        story = """
236
 
$ bzr init
 
236
$ brz init
237
237
...
238
238
$ cat >file
239
239
<Hello
240
 
$ bzr add file
 
240
$ brz add file
241
241
...
242
 
$ bzr commit -m 'adding file'
 
242
$ brz commit -m 'adding file'
243
243
2>...
244
244
"""
245
245
        self.run_script(story)
256
256
"""
257
257
        self.run_script(story)
258
258
        story = """
259
 
$ bzr not-a-command
 
259
$ brz not-a-command
260
260
2>..."not-a-command"
261
261
"""
262
262
        self.run_script(story)
263
263
 
264
264
        story = """
265
 
$ bzr branch not-a-branch
266
 
2>bzr: ERROR: Not a branch...not-a-branch/".
 
265
$ brz branch not-a-branch
 
266
2>brz: ERROR: Not a branch...not-a-branch/".
267
267
"""
268
268
        self.run_script(story)
269
269
 
297
297
        """
298
298
        # see also 656694; we should get rid of global verbosity
299
299
        self.run_script("""
300
 
        $ bzr init --quiet a
 
300
        $ brz init --quiet a
301
301
        """)
302
302
        self.assertEqual(trace.is_quiet(), False)
303
303
 
409
409
        self.assertEqual(self.test_dir, osutils.getcwd())
410
410
 
411
411
 
412
 
class TestBzr(script.TestCaseWithTransportAndScript):
 
412
class TestBrz(script.TestCaseWithTransportAndScript):
413
413
 
414
 
    def test_bzr_smoke(self):
 
414
    def test_brz_smoke(self):
415
415
        self.run_script("""
416
 
            $ bzr init branch
 
416
            $ brz init branch
417
417
            Created a standalone tree (format: ...)
418
418
            """)
419
419
        self.assertPathExists('branch')
579
579
        commands.builtin_command_registry.register(cmd_test_confirm)
580
580
        self.addCleanup(commands.builtin_command_registry.remove, 'test-confirm')
581
581
        self.run_script("""
582
 
            $ bzr test-confirm
 
582
            $ brz test-confirm
583
583
            2>Really do it? ([y]es, [n]o): yes
584
584
            <y
585
585
            Do it!
586
 
            $ bzr test-confirm
 
586
            $ brz test-confirm
587
587
            2>Really do it? ([y]es, [n]o): no
588
588
            <n
589
589
            ok, no
594
594
    def setUp(self):
595
595
        super(TestShelve, self).setUp()
596
596
        self.run_script("""
597
 
            $ bzr init test
 
597
            $ brz init test
598
598
            Created a standalone tree (format: 2a)
599
599
            $ cd test
600
600
            $ echo foo > file
601
 
            $ bzr add
 
601
            $ brz add
602
602
            adding file
603
 
            $ bzr commit -m 'file added'
 
603
            $ brz commit -m 'file added'
604
604
            2>Committing to:...test/
605
605
            2>added file
606
606
            2>Committed revision 1.
609
609
 
610
610
    def test_shelve(self):
611
611
        self.run_script("""
612
 
            $ bzr shelve -m 'shelve bar'
 
612
            $ brz shelve -m 'shelve bar'
613
613
            2>Shelve? ([y]es, [N]o, [f]inish, [q]uit): yes
614
614
            <y
615
615
            2>Selected changes:
620
620
            """,
621
621
                        null_output_matches_anything=True)
622
622
        self.run_script("""
623
 
            $ bzr shelve --list
 
623
            $ brz shelve --list
624
624
              1: shelve bar
625
625
            """)
626
626
 
627
627
    def test_dont_shelve(self):
628
628
        # We intentionally provide no input here to test EOF
629
629
        self.run_script("""
630
 
            $ bzr shelve -m 'shelve bar'
 
630
            $ brz shelve -m 'shelve bar'
631
631
            2>Shelve? ([y]es, [N]o, [f]inish, [q]uit): 
632
632
            2>No changes to shelve.
633
633
            """,
634
634
                        null_output_matches_anything=True)
635
635
        self.run_script("""
636
 
            $ bzr st
 
636
            $ brz st
637
637
            modified:
638
638
              file
639
639
            """)