/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

Merge shell-like-tests into description

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        self.assertEquals([(['bzr', 'branch', 'foo'],
69
69
                            None, None, 'bzr: ERROR: Not a branch: "foo"\n')],
70
70
                          script._script_to_commands(story))
 
71
 
71
72
    def test_input_without_command(self):
72
73
        self.assertRaises(SyntaxError, script._script_to_commands, '<input')
73
74
 
92
93
        story = """
93
94
mkdir dir
94
95
cd dir
95
 
>Hello, I have just cd into dir !
 
96
>The cd command ouputs nothing
96
97
"""
97
98
        self.assertRaises(AssertionError, self.run_script, story)
98
99
 
112
113
"""
113
114
        self.run_script(story)
114
115
 
 
116
    def test_continue_on_error_output(self):
 
117
        # The status matters, not the output
 
118
        story = """
 
119
bzr init
 
120
cat >file
 
121
<Hello
 
122
bzr add file
 
123
bzr commit -m 'adding file'
 
124
"""
 
125
        self.run_script(story)
 
126
 
115
127
    def test_ellipsis_output(self):
116
128
        story = """
117
129
cat
143
155
        self.assertRaises(SyntaxError, self.run_script, 'cat foo <bar')
144
156
 
145
157
    def test_cat_input_to_output(self):
146
 
        out, err = self.run_command(['cat'], 'content\n', 'content\n', None)
 
158
        retcode, out, err = self.run_command(['cat'],
 
159
                                             'content\n', 'content\n', None)
147
160
        self.assertEquals('content\n', out)
148
161
        self.assertEquals(None, err)
149
162
 
150
163
    def test_cat_file_to_output(self):
151
164
        self.build_tree_contents([('file', 'content\n')])
152
 
        out, err = self.run_command(['cat', 'file'], None, 'content\n', None)
 
165
        retcode, out, err = self.run_command(['cat', 'file'],
 
166
                                             None, 'content\n', None)
153
167
        self.assertEquals('content\n', out)
154
168
        self.assertEquals(None, err)
155
169
 
156
170
    def test_cat_input_to_file(self):
157
 
        out, err = self.run_command(['cat', '>file'], 'content\n', None, None)
 
171
        retcode, out, err = self.run_command(['cat', '>file'],
 
172
                                             'content\n', None, None)
158
173
        self.assertFileEqual('content\n', 'file')
159
174
        self.assertEquals(None, out)
160
175
        self.assertEquals(None, err)
161
 
        out, err = self.run_command(['cat', '>>file'], 'more\n', None, None)
 
176
        retcode, out, err = self.run_command(['cat', '>>file'],
 
177
                                             'more\n', None, None)
162
178
        self.assertFileEqual('content\nmore\n', 'file')
163
179
        self.assertEquals(None, out)
164
180
        self.assertEquals(None, err)
165
181
 
166
182
    def test_cat_file_to_file(self):
167
183
        self.build_tree_contents([('file', 'content\n')])
168
 
        out, err = self.run_command(['cat', 'file', '>file2'], None, None, None)
 
184
        retcode, out, err = self.run_command(['cat', 'file', '>file2'],
 
185
                                             None, None, None)
169
186
        self.assertFileEqual('content\n', 'file2')
170
187
 
171
188
 
229
246
        self.assertRaises(SyntaxError, self.run_script, story)
230
247
 
231
248
    def test_echo_to_output(self):
232
 
        out, err = self.run_command(['echo'], None, '\n', None)
 
249
        retcode, out, err = self.run_command(['echo'], None, '\n', None)
233
250
        self.assertEquals('\n', out)
234
251
        self.assertEquals(None, err)
235
252
 
236
253
    def test_echo_some_to_output(self):
237
 
        out, err = self.run_command(['echo', 'hello'], None, 'hello\n', None)
 
254
        retcode, out, err = self.run_command(['echo', 'hello'],
 
255
                                             None, 'hello\n', None)
238
256
        self.assertEquals('hello\n', out)
239
257
        self.assertEquals(None, err)
240
258
 
241
259
    def test_echo_more_output(self):
242
 
        out, err = self.run_command(['echo', 'hello', 'happy', 'world'],
243
 
                                    None, 'hellohappyworld\n', None)
 
260
        retcode, out, err = self.run_command(
 
261
            ['echo', 'hello', 'happy', 'world'],
 
262
            None, 'hellohappyworld\n', None)
244
263
        self.assertEquals('hellohappyworld\n', out)
245
264
        self.assertEquals(None, err)
246
265
 
247
266
    def test_echo_appended(self):
248
 
        out, err = self.run_command(['echo', 'hello', '>file'],
249
 
                                    None, None, None)
 
267
        retcode, out, err = self.run_command(['echo', 'hello', '>file'],
 
268
                                             None, None, None)
250
269
        self.assertEquals(None, out)
251
270
        self.assertEquals(None, err)
252
271
        self.assertFileEqual('hello\n', 'file')
253
 
        out, err = self.run_command(['echo', 'happy', '>>file'],
254
 
                                    None, None, None)
 
272
        retcode, out, err = self.run_command(['echo', 'happy', '>>file'],
 
273
                                             None, None, None)
255
274
        self.assertEquals(None, out)
256
275
        self.assertEquals(None, err)
257
276
        self.assertFileEqual('hello\nhappy\n', 'file')
 
277