~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-20 17:19:44 UTC
  • mfrom: (4973.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100120171944-8gkub20gotjcye67
(spiv) Implement a per-file merge hook

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""UI tests for the test framework."""
18
18
 
19
 
import os
20
 
 
 
19
import bzrlib.transport
21
20
from bzrlib import (
 
21
    benchmarks,
22
22
    tests,
23
23
    )
 
24
from bzrlib.errors import ParamikoNotPresent
24
25
from bzrlib.tests import (
25
 
    features,
26
 
    )
27
 
from bzrlib.transport import memory
 
26
                          features,
 
27
                          TestCase,
 
28
                          TestCaseInTempDir,
 
29
                          TestSkipped,
 
30
                          )
 
31
 
28
32
 
29
33
class SelfTestPatch:
30
34
 
47
51
            tests.selftest = original_selftest
48
52
 
49
53
 
50
 
class TestOptions(tests.TestCase, SelfTestPatch):
 
54
class TestOptionsWritingToDisk(TestCaseInTempDir, SelfTestPatch):
 
55
 
 
56
    def test_benchmark_runs_benchmark_tests(self):
 
57
        """selftest --benchmark should change the suite factory."""
 
58
        params = self.get_params_passed_to_core('selftest --benchmark')
 
59
        self.assertEqual(benchmarks.test_suite,
 
60
            params[1]['test_suite_factory'])
 
61
        self.assertNotEqual(None, params[1]['bench_history'])
 
62
        benchfile = open(".perf_history", "rt")
 
63
        try:
 
64
            lines = benchfile.readlines()
 
65
        finally:
 
66
            benchfile.close()
 
67
        # Because we don't run the actual test code no output is made to the
 
68
        # file.
 
69
        self.assertEqual(0, len(lines))
 
70
 
 
71
 
 
72
class TestOptions(TestCase, SelfTestPatch):
51
73
 
52
74
    def test_load_list(self):
53
75
        params = self.get_params_passed_to_core('selftest --load-list foo')
57
79
        # Test that we can pass a transport to the selftest core - sftp
58
80
        # version.
59
81
        self.requireFeature(features.paramiko)
60
 
        from bzrlib.tests import stub_sftp
61
82
        params = self.get_params_passed_to_core('selftest --transport=sftp')
62
 
        self.assertEqual(stub_sftp.SFTPAbsoluteServer,
 
83
        self.assertEqual(bzrlib.transport.sftp.SFTPAbsoluteServer,
63
84
            params[1]["transport"])
64
85
 
65
86
    def test_transport_set_to_memory(self):
66
87
        # Test that we can pass a transport to the selftest core - memory
67
88
        # version.
 
89
        import bzrlib.transport.memory
68
90
        params = self.get_params_passed_to_core('selftest --transport=memory')
69
 
        self.assertEqual(memory.MemoryServer, params[1]["transport"])
 
91
        self.assertEqual(bzrlib.transport.memory.MemoryServer,
 
92
            params[1]["transport"])
70
93
 
71
94
    def test_parameters_passed_to_core(self):
72
95
        params = self.get_params_passed_to_core('selftest --list-only')
150
173
    def test_lsprof_tests(self):
151
174
        params = self.get_params_passed_to_core('selftest --lsprof-tests')
152
175
        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)