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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 19:47:19 UTC
  • mfrom: (7178 work)
  • mto: This revision was merged to the branch mainline in revision 7179.
  • Revision ID: jelmer@jelmer.uk-20181116194719-m5ut2wfuze5x9s1p
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
    def test_simple_command(self):
62
62
        self.assertEqual([(['cd', 'trunk'], None, None, None)],
63
 
                           script._script_to_commands('$ cd trunk'))
 
63
                         script._script_to_commands('$ cd trunk'))
64
64
 
65
65
    def test_command_with_single_quoted_param(self):
66
66
        story = """$ brz commit -m 'two words'"""
67
67
        self.assertEqual([(['brz', 'commit', '-m', "'two words'"],
68
 
                            None, None, None)],
69
 
                           script._script_to_commands(story))
 
68
                           None, None, None)],
 
69
                         script._script_to_commands(story))
70
70
 
71
71
    def test_command_with_double_quoted_param(self):
72
72
        story = """$ brz commit -m "two words" """
73
73
        self.assertEqual([(['brz', 'commit', '-m', '"two words"'],
74
 
                            None, None, None)],
75
 
                           script._script_to_commands(story))
 
74
                           None, None, None)],
 
75
                         script._script_to_commands(story))
76
76
 
77
77
    def test_command_with_input(self):
78
78
        self.assertEqual(
88
88
            adding file2
89
89
            """
90
90
        self.assertEqual([(['brz', 'add'], None,
91
 
                            'adding file\nadding file2\n', None)],
92
 
                          script._script_to_commands(story))
 
91
                           'adding file\nadding file2\n', None)],
 
92
                         script._script_to_commands(story))
93
93
 
94
94
    def test_command_with_output(self):
95
95
        story = """
98
98
adding file2
99
99
"""
100
100
        self.assertEqual([(['brz', 'add'], None,
101
 
                            'adding file\nadding file2\n', None)],
102
 
                          script._script_to_commands(story))
 
101
                           'adding file\nadding file2\n', None)],
 
102
                         script._script_to_commands(story))
103
103
 
104
104
    def test_command_with_error(self):
105
105
        story = """
107
107
2>brz: ERROR: Not a branch: "foo"
108
108
"""
109
109
        self.assertEqual([(['brz', 'branch', 'foo'],
110
 
                            None, None, 'brz: ERROR: Not a branch: "foo"\n')],
111
 
                          script._script_to_commands(story))
 
110
                           None, None, 'brz: ERROR: Not a branch: "foo"\n')],
 
111
                         script._script_to_commands(story))
112
112
 
113
113
    def test_input_without_command(self):
114
114
        self.assertRaises(SyntaxError, script._script_to_commands, '<input')
121
121
$ foo = `brz file-id toto`
122
122
"""
123
123
        self.assertEqual([(['foo', '=', '`brz file-id toto`'],
124
 
                            None, None, None)],
125
 
                          script._script_to_commands(story))
 
124
                           None, None, None)],
 
125
                         script._script_to_commands(story))
126
126
 
127
127
 
128
128
class TestRedirections(tests.TestCase):
157
157
        self._check('>', '', 'a+', [], ['<', '>', '>>'])
158
158
 
159
159
 
160
 
 
161
160
class TestExecution(script.TestCaseWithTransportAndScript):
162
161
 
163
162
    def test_unknown_command(self):
176
175
 
177
176
    def test_blank_output_mismatches_output(self):
178
177
        """If you give output, the output must actually be blank.
179
 
        
 
178
 
180
179
        See <https://bugs.launchpad.net/bzr/+bug/637830>: previously blank
181
180
        output was a wildcard.  Now you must say ... if you want that.
182
181
        """
183
182
        self.assertRaises(AssertionError,
184
 
            self.run_script,
185
 
            """
 
183
                          self.run_script,
 
184
                          """
186
185
            $ echo foo
187
186
            """)
188
187
 
374
373
 
375
374
    def test_mkdir_jailed(self):
376
375
        self.assertRaises(ValueError, self.run_script, '$ mkdir /out-of-jail')
377
 
        self.assertRaises(ValueError, self.run_script, '$ mkdir ../out-of-jail')
 
376
        self.assertRaises(ValueError, self.run_script,
 
377
                          '$ mkdir ../out-of-jail')
378
378
 
379
379
    def test_mkdir_in_jail(self):
380
380
        self.run_script("""
403
403
$ cd dir
404
404
""")
405
405
        self.assertEqual(osutils.pathjoin(self.test_dir, 'dir'),
406
 
                          osutils.getcwd())
 
406
                         osutils.getcwd())
407
407
 
408
408
        self.run_script('$ cd')
409
409
        self.assertEqual(self.test_dir, osutils.getcwd())
558
558
 
559
559
    def run(self):
560
560
        if ui.ui_factory.get_boolean(
561
 
            u'Really do it',
562
 
            # 'breezy.tests.test_script.confirm',
563
 
            # {}
564
 
            ):
 
561
                u'Really do it',
 
562
                # 'breezy.tests.test_script.confirm',
 
563
                # {}
 
564
                ):
565
565
            self.outf.write('Do it!\n')
566
566
        else:
567
567
            print('ok, no')
571
571
 
572
572
    def test_confirm_action(self):
573
573
        """You can write tests that demonstrate user confirmation.
574
 
        
 
574
 
575
575
        Specifically, ScriptRunner does't care if the output line for the
576
576
        prompt isn't terminated by a newline from the program; it's implicitly
577
577
        terminated by the input.
578
578
        """
579
579
        commands.builtin_command_registry.register(cmd_test_confirm)
580
 
        self.addCleanup(commands.builtin_command_registry.remove, 'test-confirm')
 
580
        self.addCleanup(
 
581
            commands.builtin_command_registry.remove, 'test-confirm')
581
582
        self.run_script("""
582
583
            $ brz test-confirm
583
584
            2>Really do it? ([y]es, [n]o): yes
589
590
            ok, no
590
591
            """)
591
592
 
 
593
 
592
594
class TestShelve(script.TestCaseWithTransportAndScript):
593
595
 
594
596
    def setUp(self):