/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/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-07-25 21:54:01 UTC
  • Revision ID: mbp@sourcefrog.net-20050725215401-0bed2682b7fee8b5
- fix bugs and add tests for doing commit of selected directories

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
 
 
18
from testsweet import TestBase, run_suite, InTempDir
 
19
import bzrlib.commands
 
20
 
 
21
MODULES_TO_TEST = []
 
22
MODULES_TO_DOCTEST = []
 
23
 
 
24
 
 
25
class BzrTestBase(InTempDir):
 
26
    """bzr-specific test base class"""
 
27
    def run_bzr(self, *args, **kwargs):
 
28
        retcode = kwargs.get('retcode', 0)
 
29
        self.assertEquals(bzrlib.commands.run_bzr(args), retcode)
 
30
        
 
31
 
 
32
def selftest(verbose=False):
 
33
    from unittest import TestLoader, TestSuite
 
34
    import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch
 
35
    import bzrlib.osutils, bzrlib.commands, bzrlib.merge3, bzrlib.plugin
 
36
    global MODULES_TO_TEST, MODULES_TO_DOCTEST
 
37
 
 
38
    import bzrlib.selftest.whitebox
 
39
    import bzrlib.selftest.blackbox
 
40
    import bzrlib.selftest.versioning
 
41
    import bzrlib.selftest.testmerge3
 
42
    import bzrlib.selftest.testhashcache
 
43
    import bzrlib.selftest.testrevisionnamespaces
 
44
    import bzrlib.selftest.testbranch
 
45
    import bzrlib.selftest.teststatus
 
46
    import bzrlib.selftest.testinv
 
47
    import bzrlib.merge_core
 
48
    from doctest import DocTestSuite
 
49
    import os
 
50
    import shutil
 
51
    import time
 
52
    import sys
 
53
    import unittest
 
54
 
 
55
    for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch,
 
56
              bzrlib.osutils, bzrlib.commands, bzrlib.merge3):
 
57
        if m not in MODULES_TO_DOCTEST:
 
58
            MODULES_TO_DOCTEST.append(m)
 
59
    
 
60
    # ugly ugly!
 
61
    for m in (bzrlib.selftest.whitebox,
 
62
              bzrlib.selftest.versioning,
 
63
              bzrlib.selftest.testinv,
 
64
              bzrlib.selftest.testmerge3,
 
65
              bzrlib.selftest.testhashcache,
 
66
              bzrlib.selftest.teststatus,
 
67
              bzrlib.selftest.blackbox,
 
68
              bzrlib.selftest.testhashcache,
 
69
              bzrlib.selftest.testrevisionnamespaces,
 
70
              bzrlib.selftest.testbranch,
 
71
              ):
 
72
        if m not in MODULES_TO_TEST:
 
73
            MODULES_TO_TEST.append(m)
 
74
 
 
75
 
 
76
    TestBase.BZRPATH = os.path.join(os.path.realpath(os.path.dirname(bzrlib.__path__[0])), 'bzr')
 
77
    print '%-30s %s' % ('bzr binary', TestBase.BZRPATH)
 
78
 
 
79
    print
 
80
 
 
81
    suite = TestSuite()
 
82
 
 
83
    # should also test bzrlib.merge_core, but they seem to be out of date with
 
84
    # the code.
 
85
 
 
86
 
 
87
    # XXX: python2.3's TestLoader() doesn't seem to find all the
 
88
    # tests; don't know why
 
89
    for m in MODULES_TO_TEST:
 
90
         suite.addTest(TestLoader().loadTestsFromModule(m))
 
91
 
 
92
    for m in (MODULES_TO_DOCTEST):
 
93
        suite.addTest(DocTestSuite(m))
 
94
 
 
95
    for p in bzrlib.plugin.all_plugins:
 
96
        if hasattr(p, 'test_suite'):
 
97
            suite.addTest(p.test_suite())
 
98
 
 
99
    suite.addTest(unittest.makeSuite(bzrlib.merge_core.MergeTest, 'test_'))
 
100
 
 
101
    return run_suite(suite, 'testbzr', verbose=verbose)
 
102
 
 
103
 
 
104