18
18
from unittest import TestResult, TestCase
21
class TestBase(TestCase):
22
"""Base class for bzr test cases.
24
Just defines some useful helper functions; doesn't actually test
27
# TODO: Special methods to invoke bzr
29
def runcmd(self, cmd, expected=0):
30
self.log('$ ' + ' '.join(cmd))
31
from os import spawnvp, P_WAIT
32
rc = spawnvp(P_WAIT, cmd[0], cmd)
34
self.fail("command %r returned status %d" % (cmd, rc))
37
def backtick(self, cmd):
38
"""Run a command and return its output"""
40
self.log('$ ' + ' '.join(cmd))
51
self.fail("command %r returned status %d" % (cmd, rc))
57
"""Log a message to a progress file"""
20
63
class _MyResult(TestResult):
67
No special behaviour for now.
21
69
# def startTest(self, test):
22
70
# print str(test).ljust(50),
23
71
# TestResult.startTest(self, test)
36
from unittest import TestLoader, TestSuite
38
import bzrlib.whitebox
39
import bzrlib.blackbox
40
from doctest import DocTestSuite
45
for m in bzrlib.whitebox, bzrlib.blackbox:
46
suite.addTest(tl.loadTestsFromModule(m))
48
for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
50
suite.addTest(DocTestSuite(m))
84
from unittest import TestLoader, TestSuite
86
import bzrlib.whitebox
87
import bzrlib.blackbox
88
from doctest import DocTestSuite
99
for m in bzrlib.whitebox, bzrlib.blackbox:
100
suite.addTest(tl.loadTestsFromModule(m))
102
for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
104
suite.addTest(DocTestSuite(m))
109
_show_results(result)
111
return result.wasSuccessful()
114
def _setup_test_log():
119
log_filename = os.path.abspath('testbzr.log')
120
TEST_LOG = open(log_filename, 'wt', buffering=1) # line buffered
122
print >>TEST_LOG, "bzr tests run at " + time.ctime()
123
print '%-30s %s' % ('test log', log_filename)
126
def _setup_test_dir():
130
global ORIG_DIR, TEST_DIR
131
ORIG_DIR = os.getcwdu()
132
TEST_DIR = os.path.abspath("testbzr.tmp")
134
print '%-30s %s' % ('running tests in', TEST_DIR)
136
if os.path.exists(TEST_DIR):
137
shutil.rmtree(TEST_DIR)
143
def _show_results(result):
144
for case, tb in result.errors:
145
_show_test_failure('ERROR', case, tb)
147
for case, tb in result.failures:
148
_show_test_failure('FAILURE', case, tb)
55
151
print '%4d tests run' % result.testsRun
56
152
print '%4d errors' % len(result.errors)
57
153
print '%4d failures' % len(result.failures)
59
return result.wasSuccessful()
157
def _show_test_failure(kind, case, tb):
158
print (kind + '! ').ljust(60, '-')
161
print ''.ljust(60, '-')