~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-02-23 07:43:11 UTC
  • mfrom: (4797.2.20 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: mbp@sourcefrog.net-20100223074311-gnj55xdhrgz9l94e
Merge 2.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""UI tests for the test framework."""
18
18
 
19
 
import os
20
 
 
21
19
from bzrlib import (
 
20
    benchmarks,
22
21
    tests,
23
22
    )
24
23
from bzrlib.tests import (
25
24
    features,
 
25
    stub_sftp,
26
26
    )
27
27
from bzrlib.transport import memory
28
28
 
47
47
            tests.selftest = original_selftest
48
48
 
49
49
 
 
50
class TestOptionsWritingToDisk(tests.TestCaseInTempDir, SelfTestPatch):
 
51
 
 
52
    def test_benchmark_runs_benchmark_tests(self):
 
53
        """selftest --benchmark should change the suite factory."""
 
54
        params = self.get_params_passed_to_core('selftest --benchmark')
 
55
        self.assertEqual(benchmarks.test_suite,
 
56
            params[1]['test_suite_factory'])
 
57
        self.assertNotEqual(None, params[1]['bench_history'])
 
58
        benchfile = open(".perf_history", "rt")
 
59
        try:
 
60
            lines = benchfile.readlines()
 
61
        finally:
 
62
            benchfile.close()
 
63
        # Because we don't run the actual test code no output is made to the
 
64
        # file.
 
65
        self.assertEqual(0, len(lines))
 
66
 
 
67
 
50
68
class TestOptions(tests.TestCase, SelfTestPatch):
51
69
 
52
70
    def test_load_list(self):
57
75
        # Test that we can pass a transport to the selftest core - sftp
58
76
        # version.
59
77
        self.requireFeature(features.paramiko)
60
 
        from bzrlib.tests import stub_sftp
61
78
        params = self.get_params_passed_to_core('selftest --transport=sftp')
62
79
        self.assertEqual(stub_sftp.SFTPAbsoluteServer,
63
80
            params[1]["transport"])
150
167
    def test_lsprof_tests(self):
151
168
        params = self.get_params_passed_to_core('selftest --lsprof-tests')
152
169
        self.assertEqual(True, params[1]["lsprof_tests"])
153
 
 
154
 
    def test_parallel_fork_unsupported(self):
155
 
        if getattr(os, "fork", None) is not None:
156
 
            self.addCleanup(setattr, os, "fork", os.fork)
157
 
            del os.fork
158
 
        out, err = self.run_bzr(["selftest", "--parallel=fork", "-s", "bt.x"],
159
 
            retcode=3)
160
 
        self.assertIn("platform does not support fork", err)
161
 
        self.assertFalse(out)