/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/blackbox/test_selftest.py

Merge from TestCaseWithMemoryTransport.

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
25
26
from bzrlib.errors import ParamikoNotPresent
26
27
from bzrlib.tests import (
27
28
                          TestCase,
28
 
                          TestCaseInTempDir,
 
29
                          TestCaseWithMemoryTransport,
29
30
                          TestCaseWithTransport,
30
31
                          TestSkipped,
31
32
                          )
64
65
        except ParamikoNotPresent:
65
66
            raise TestSkipped("Paramiko not present")
66
67
        old_transport = bzrlib.tests.default_transport
67
 
        old_root = TestCaseInTempDir.TEST_ROOT
68
 
        TestCaseInTempDir.TEST_ROOT = None
 
68
        old_root = TestCaseWithMemoryTransport.TEST_ROOT
 
69
        TestCaseWithMemoryTransport.TEST_ROOT = None
69
70
        try:
70
71
            TestOptions.current_test = "test_transport_set_to_sftp"
71
72
            stdout = self.capture('selftest --transport=sftp test_transport_set_to_sftp')
80
81
        finally:
81
82
            bzrlib.tests.default_transport = old_transport
82
83
            TestOptions.current_test = None
83
 
            TestCaseInTempDir.TEST_ROOT = old_root
 
84
            TestCaseWithMemoryTransport.TEST_ROOT = old_root
84
85
 
85
86
 
86
87
class TestRunBzr(ExternalBase):
106
107
        """bzr selftest --benchmark should not run the default test suite."""
107
108
        # We test this by passing a regression test name to --benchmark, which
108
109
        # should result in 0 rests run.
109
 
        old_root = TestCaseInTempDir.TEST_ROOT
 
110
        old_root = TestCaseWithMemoryTransport.TEST_ROOT
110
111
        try:
111
 
            TestCaseInTempDir.TEST_ROOT = None
 
112
            TestCaseWithMemoryTransport.TEST_ROOT = None
112
113
            out, err = self.run_bzr('selftest', '--benchmark', 'workingtree_implementations')
113
114
        finally:
114
 
            TestCaseInTempDir.TEST_ROOT = old_root
 
115
            TestCaseWithMemoryTransport.TEST_ROOT = old_root
115
116
        self.assertContainsRe(out, 'Ran 0 tests.*\n\nOK')
116
117
        self.assertEqual(
117
118
            'running tests...\ntests passed\n',
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