~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_selftest.py

  • Committer: Robert Collins
  • Date: 2006-09-17 21:03:04 UTC
  • mfrom: (2018 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2019.
  • Revision ID: robertc@robertcollins.net-20060917210304-3a697132f5fb68ac
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
"""UI tests for the test framework."""
17
17
 
18
18
import os
 
19
import signal
19
20
import sys
20
21
 
21
22
import bzrlib
243
244
        self.assertEqual('it sure does!\n', out)
244
245
        self.assertEqual('', err)
245
246
 
 
247
    def test_start_and_stop_bzr_subprocess(self):
 
248
        """We can start and perform other test actions while that process is
 
249
        still alive.
 
250
        """
 
251
        process = self.start_bzr_subprocess(['--version'])
 
252
        result = self.finish_bzr_subprocess(process)
 
253
        self.assertContainsRe(result[0], 'is free software')
 
254
        self.assertEqual('', result[1])
 
255
 
 
256
    def test_start_and_stop_bzr_subprocess_with_error(self):
 
257
        """finish_bzr_subprocess allows specification of the desired exit code.
 
258
        """
 
259
        process = self.start_bzr_subprocess(['--versionn'])
 
260
        result = self.finish_bzr_subprocess(process, retcode=3)
 
261
        self.assertEqual('', result[0])
 
262
        self.assertContainsRe(result[1], 'unknown command')
 
263
 
 
264
    def test_start_and_stop_bzr_subprocess_ignoring_retcode(self):
 
265
        """finish_bzr_subprocess allows the exit code to be ignored."""
 
266
        process = self.start_bzr_subprocess(['--versionn'])
 
267
        result = self.finish_bzr_subprocess(process, retcode=None)
 
268
        self.assertEqual('', result[0])
 
269
        self.assertContainsRe(result[1], 'unknown command')
 
270
 
 
271
    def test_start_and_stop_bzr_subprocess_with_unexpected_retcode(self):
 
272
        """finish_bzr_subprocess raises self.failureException if the retcode is
 
273
        not the expected one.
 
274
        """
 
275
        process = self.start_bzr_subprocess(['--versionn'])
 
276
        self.assertRaises(self.failureException, self.finish_bzr_subprocess,
 
277
                          process, retcode=0)
 
278
        
 
279
    def test_start_and_stop_bzr_subprocess_send_signal(self):
 
280
        """finish_bzr_subprocess raises self.failureException if the retcode is
 
281
        not the expected one.
 
282
        """
 
283
        process = self.start_bzr_subprocess(['wait-until-signalled'],
 
284
                                            skip_if_plan_to_signal=True)
 
285
        self.assertEqual('running\n', process.stdout.readline())
 
286
        result = self.finish_bzr_subprocess(process, send_signal=signal.SIGINT,
 
287
                                            retcode=3)
 
288
        self.assertEqual('', result[0])
 
289
        self.assertEqual('bzr: interrupted\n', result[1])
 
290
        
246
291
 
247
292
class TestRunBzrError(ExternalBase):
248
293