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

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    )
27
27
from breezy.transport import memory
28
28
 
29
 
 
30
29
class SelfTestPatch:
31
30
 
32
31
    def get_params_passed_to_core(self, cmdline):
33
32
        params = []
34
 
 
35
33
        def selftest(*args, **kwargs):
36
34
            """Capture the arguments selftest was run with."""
37
35
            params.append((args, kwargs))
38
36
            return True
39
37
        # Yes this prevents using threads to run the test suite in parallel,
40
 
        # however we don't have a clean dependency injector for commands,
 
38
        # however we don't have a clean dependency injector for commands, 
41
39
        # and even if we did - we'd still be testing that the glue is wired
42
40
        # up correctly. XXX: TODO: Solve this testing problem.
43
41
        original_selftest = tests.selftest
62
60
        from breezy.tests import stub_sftp
63
61
        params = self.get_params_passed_to_core('selftest --transport=sftp')
64
62
        self.assertEqual(stub_sftp.SFTPAbsoluteServer,
65
 
                         params[1]["transport"])
 
63
            params[1]["transport"])
66
64
 
67
65
    def test_transport_set_to_memory(self):
68
66
        # Test that we can pass a transport to the selftest core - memory
73
71
    def test_parameters_passed_to_core(self):
74
72
        params = self.get_params_passed_to_core('selftest --list-only')
75
73
        self.assertTrue("list_only" in params[1])
76
 
        params = self.get_params_passed_to_core(
77
 
            'selftest --list-only selftest')
78
 
        self.assertTrue("list_only" in params[1])
79
 
        params = self.get_params_passed_to_core(['selftest', '--list-only',
80
 
                                                 '--exclude', 'selftest'])
81
 
        self.assertTrue("list_only" in params[1])
82
 
        params = self.get_params_passed_to_core(['selftest', '--list-only',
83
 
                                                 'selftest', '--randomize', 'now'])
 
74
        params = self.get_params_passed_to_core('selftest --list-only selftest')
 
75
        self.assertTrue("list_only" in params[1])
 
76
        params = self.get_params_passed_to_core(['selftest', '--list-only',
 
77
            '--exclude', 'selftest'])
 
78
        self.assertTrue("list_only" in params[1])
 
79
        params = self.get_params_passed_to_core(['selftest', '--list-only',
 
80
            'selftest', '--randomize', 'now'])
84
81
        self.assertSubset(["list_only", "random_seed"], params[1])
85
82
 
86
83
    def test_starting_with(self):
135
132
        def selftest(*args, **kwargs):
136
133
            """Capture the arguments selftest was run with."""
137
134
            return True
138
 
 
139
135
        def outputs_nothing(cmdline):
140
136
            out, err = self.run_bzr(cmdline)
141
137
            (header, body, footer) = self._parse_test_list(out.splitlines())
144
140
            self.assertLength(0, footer)
145
141
            self.assertEqual('', err)
146
142
        # Yes this prevents using threads to run the test suite in parallel,
147
 
        # however we don't have a clean dependency injector for commands,
 
143
        # however we don't have a clean dependency injector for commands, 
148
144
        # and even if we did - we'd still be testing that the glue is wired
149
145
        # up correctly. XXX: TODO: Solve this testing problem.
150
146
        original_selftest = tests.selftest
152
148
        try:
153
149
            outputs_nothing('selftest --list-only')
154
150
            outputs_nothing('selftest --list-only selftest')
155
 
            outputs_nothing(
156
 
                ['selftest', '--list-only', '--exclude', 'selftest'])
 
151
            outputs_nothing(['selftest', '--list-only', '--exclude', 'selftest'])
157
152
        finally:
158
153
            tests.selftest = original_selftest
159
154
 
166
161
            self.addCleanup(setattr, os, "fork", os.fork)
167
162
            del os.fork
168
163
        out, err = self.run_bzr(["selftest", "--parallel=fork", "-s", "bt.x"],
169
 
                                retcode=3)
 
164
            retcode=3)
170
165
        self.assertIn("platform does not support fork", err)
171
166
        self.assertFalse(out)