/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

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

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