608
by Martin Pool
- Split selftests out into a new module and start changing them |
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 |
||
609
by Martin Pool
- cleanup test code |
17 |
|
1185.1.29
by Robert Collins
merge merge tweaks from aaron, which includes latest .dev |
18 |
from cStringIO import StringIO |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
19 |
import logging |
20 |
import unittest |
|
21 |
import tempfile |
|
22 |
import os |
|
1139
by Martin Pool
- merge in merge improvements and additional tests |
23 |
import sys |
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
24 |
import errno |
1143
by Martin Pool
- remove dead code and remove some small errors (pychecker) |
25 |
import subprocess |
1185.3.9
by Martin Pool
- name test tmpdirs sequentially, not randomly |
26 |
import shutil |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
27 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
28 |
import bzrlib.commands |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
29 |
import bzrlib.trace |
974.1.27
by aaron.bentley at utoronto
Initial greedy fetch work |
30 |
import bzrlib.fetch |
1393.1.6
by Martin Pool
- fold testsweet into bzrlib.selftest |
31 |
from bzrlib.selftest import TestUtil |
32 |
from bzrlib.selftest.TestUtil import TestLoader, TestSuite |
|
719
by Martin Pool
- reorganize selftest code |
33 |
|
1147
by Martin Pool
- split builtin commands into separate module bzrlib.builtins; |
34 |
|
855
by Martin Pool
- Patch from John to allow plugins to add their own tests. |
35 |
MODULES_TO_TEST = [] |
36 |
MODULES_TO_DOCTEST = [] |
|
720
by Martin Pool
- start moving external tests into the testsuite framework |
37 |
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
38 |
from logging import debug, warning, error |
39 |
||
1393.1.6
by Martin Pool
- fold testsweet into bzrlib.selftest |
40 |
|
41 |
||
42 |
class EarlyStoppingTestResultAdapter(object): |
|
43 |
"""An adapter for TestResult to stop at the first first failure or error"""
|
|
44 |
||
45 |
def __init__(self, result): |
|
46 |
self._result = result |
|
47 |
||
48 |
def addError(self, test, err): |
|
49 |
self._result.addError(test, err) |
|
50 |
self._result.stop() |
|
51 |
||
52 |
def addFailure(self, test, err): |
|
53 |
self._result.addFailure(test, err) |
|
54 |
self._result.stop() |
|
55 |
||
56 |
def __getattr__(self, name): |
|
57 |
return getattr(self._result, name) |
|
58 |
||
59 |
def __setattr__(self, name, value): |
|
60 |
if name == '_result': |
|
61 |
object.__setattr__(self, name, value) |
|
62 |
return setattr(self._result, name, value) |
|
63 |
||
64 |
||
65 |
class _MyResult(unittest._TextTestResult): |
|
66 |
"""
|
|
67 |
Custom TestResult.
|
|
68 |
||
69 |
No special behaviour for now.
|
|
70 |
"""
|
|
71 |
||
72 |
def startTest(self, test): |
|
73 |
unittest.TestResult.startTest(self, test) |
|
74 |
# TODO: Maybe show test.shortDescription somewhere?
|
|
75 |
what = test.shortDescription() or test.id() |
|
76 |
if self.showAll: |
|
77 |
self.stream.write('%-70.70s' % what) |
|
78 |
self.stream.flush() |
|
79 |
||
80 |
def addError(self, test, err): |
|
81 |
super(_MyResult, self).addError(test, err) |
|
82 |
self.stream.flush() |
|
83 |
||
84 |
def addFailure(self, test, err): |
|
85 |
super(_MyResult, self).addFailure(test, err) |
|
86 |
self.stream.flush() |
|
87 |
||
88 |
def addSuccess(self, test): |
|
89 |
if self.showAll: |
|
90 |
self.stream.writeln('OK') |
|
91 |
elif self.dots: |
|
92 |
self.stream.write('~') |
|
93 |
self.stream.flush() |
|
94 |
unittest.TestResult.addSuccess(self, test) |
|
95 |
||
96 |
def printErrorList(self, flavour, errors): |
|
97 |
for test, err in errors: |
|
98 |
self.stream.writeln(self.separator1) |
|
99 |
self.stream.writeln("%s: %s" % (flavour,self.getDescription(test))) |
|
100 |
if hasattr(test, '_get_log'): |
|
101 |
self.stream.writeln() |
|
102 |
self.stream.writeln('log from this test:') |
|
103 |
print >>self.stream, test._get_log() |
|
104 |
self.stream.writeln(self.separator2) |
|
105 |
self.stream.writeln("%s" % err) |
|
106 |
||
107 |
||
108 |
class TextTestRunner(unittest.TextTestRunner): |
|
109 |
||
110 |
def _makeResult(self): |
|
111 |
result = _MyResult(self.stream, self.descriptions, self.verbosity) |
|
112 |
return EarlyStoppingTestResultAdapter(result) |
|
113 |
||
114 |
||
115 |
class filteringVisitor(TestUtil.TestVisitor): |
|
116 |
"""I accruse all the testCases I visit that pass a regexp filter on id
|
|
117 |
into my suite
|
|
118 |
"""
|
|
119 |
||
120 |
def __init__(self, filter): |
|
121 |
import re |
|
122 |
TestUtil.TestVisitor.__init__(self) |
|
123 |
self._suite=None |
|
124 |
self.filter=re.compile(filter) |
|
125 |
||
126 |
def suite(self): |
|
127 |
"""answer the suite we are building"""
|
|
128 |
if self._suite is None: |
|
129 |
self._suite=TestUtil.TestSuite() |
|
130 |
return self._suite |
|
131 |
||
132 |
def visitCase(self, aCase): |
|
133 |
if self.filter.match(aCase.id()): |
|
134 |
self.suite().addTest(aCase) |
|
135 |
||
136 |
class TestSkipped(Exception): |
|
137 |
"""Indicates that a test was intentionally skipped, rather than failing."""
|
|
138 |
# XXX: Not used yet
|
|
139 |
||
140 |
||
1147
by Martin Pool
- split builtin commands into separate module bzrlib.builtins; |
141 |
class CommandFailed(Exception): |
142 |
pass
|
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
143 |
|
144 |
class TestCase(unittest.TestCase): |
|
145 |
"""Base class for bzr unit tests.
|
|
146 |
|
|
147 |
Tests that need access to disk resources should subclass
|
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
148 |
TestCaseInTempDir not TestCase.
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
149 |
|
150 |
Error and debug log messages are redirected from their usual
|
|
151 |
location into a temporary file, the contents of which can be
|
|
152 |
retrieved by _get_log().
|
|
153 |
|
|
154 |
There are also convenience functions to invoke bzr's command-line
|
|
155 |
routine, and to build and check bzr trees."""
|
|
156 |
||
157 |
BZRPATH = 'bzr' |
|
158 |
||
159 |
def setUp(self): |
|
160 |
unittest.TestCase.setUp(self) |
|
161 |
bzrlib.trace.disable_default_logging() |
|
162 |
self._enable_file_logging() |
|
163 |
||
164 |
||
165 |
def _enable_file_logging(self): |
|
166 |
fileno, name = tempfile.mkstemp(suffix='.log', prefix='testbzr') |
|
167 |
||
168 |
self._log_file = os.fdopen(fileno, 'w+') |
|
169 |
||
170 |
hdlr = logging.StreamHandler(self._log_file) |
|
171 |
hdlr.setLevel(logging.DEBUG) |
|
1215
by Martin Pool
- change trace format for test logs |
172 |
hdlr.setFormatter(logging.Formatter('%(levelname)8s %(message)s')) |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
173 |
logging.getLogger('').addHandler(hdlr) |
174 |
logging.getLogger('').setLevel(logging.DEBUG) |
|
175 |
self._log_hdlr = hdlr |
|
176 |
debug('opened log file %s', name) |
|
177 |
||
178 |
self._log_file_name = name |
|
179 |
||
180 |
def tearDown(self): |
|
181 |
logging.getLogger('').removeHandler(self._log_hdlr) |
|
182 |
bzrlib.trace.enable_default_logging() |
|
183 |
logging.debug('%s teardown', self.id()) |
|
184 |
self._log_file.close() |
|
185 |
unittest.TestCase.tearDown(self) |
|
186 |
||
187 |
def log(self, *args): |
|
188 |
logging.debug(*args) |
|
189 |
||
190 |
def _get_log(self): |
|
191 |
"""Return as a string the log for this test"""
|
|
192 |
return open(self._log_file_name).read() |
|
193 |
||
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
194 |
|
1185.3.26
by Martin Pool
- remove remaining external executions of bzr |
195 |
def capture(self, cmd): |
196 |
"""Shortcut that splits cmd into words, runs, and returns stdout"""
|
|
197 |
return self.run_bzr_captured(cmd.split())[0] |
|
198 |
||
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
199 |
def run_bzr_captured(self, argv, retcode=0): |
200 |
"""Invoke bzr and return (result, stdout, stderr).
|
|
201 |
||
202 |
Useful for code that wants to check the contents of the
|
|
203 |
output, the way error messages are presented, etc.
|
|
204 |
||
205 |
This should be the main method for tests that want to exercise the
|
|
206 |
overall behavior of the bzr application (rather than a unit test
|
|
207 |
or a functional test of the library.)
|
|
208 |
||
209 |
Much of the old code runs bzr by forking a new copy of Python, but
|
|
210 |
that is slower, harder to debug, and generally not necessary.
|
|
211 |
||
1185.3.20
by Martin Pool
- run_bzr_captured also includes logged errors in |
212 |
This runs bzr through the interface that catches and reports
|
213 |
errors, and with logging set to something approximating the
|
|
214 |
default, so that error reporting can be checked.
|
|
215 |
||
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
216 |
argv -- arguments to invoke bzr
|
217 |
retcode -- expected return code, or None for don't-care.
|
|
218 |
"""
|
|
219 |
stdout = StringIO() |
|
220 |
stderr = StringIO() |
|
221 |
self.log('run bzr: %s', ' '.join(argv)) |
|
1185.3.20
by Martin Pool
- run_bzr_captured also includes logged errors in |
222 |
handler = logging.StreamHandler(stderr) |
223 |
handler.setFormatter(bzrlib.trace.QuietFormatter()) |
|
224 |
handler.setLevel(logging.INFO) |
|
225 |
logger = logging.getLogger('') |
|
226 |
logger.addHandler(handler) |
|
227 |
try: |
|
228 |
result = self.apply_redirected(None, stdout, stderr, |
|
229 |
bzrlib.commands.run_bzr_catch_errors, |
|
230 |
argv) |
|
231 |
finally: |
|
232 |
logger.removeHandler(handler) |
|
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
233 |
out = stdout.getvalue() |
234 |
err = stderr.getvalue() |
|
235 |
if out: |
|
236 |
self.log('output:\n%s', out) |
|
237 |
if err: |
|
238 |
self.log('errors:\n%s', err) |
|
239 |
if retcode is not None: |
|
240 |
self.assertEquals(result, retcode) |
|
241 |
return out, err |
|
242 |
||
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
243 |
def run_bzr(self, *args, **kwargs): |
1119
by Martin Pool
doc |
244 |
"""Invoke bzr, as if it were run from the command line.
|
245 |
||
246 |
This should be the main method for tests that want to exercise the
|
|
247 |
overall behavior of the bzr application (rather than a unit test
|
|
248 |
or a functional test of the library.)
|
|
249 |
||
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
250 |
This sends the stdout/stderr results into the test's log,
|
251 |
where it may be useful for debugging. See also run_captured.
|
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
252 |
"""
|
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
253 |
retcode = kwargs.pop('retcode', 0) |
1185.3.21
by Martin Pool
TestBase.run_bzr doesn't need to be deprecated |
254 |
return self.run_bzr_captured(args, retcode) |
1185.3.18
by Martin Pool
- add new helper TestBase.run_bzr_captured |
255 |
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
256 |
def check_inventory_shape(self, inv, shape): |
1291
by Martin Pool
- add test for moving files between directories |
257 |
"""Compare an inventory to a list of expected names.
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
258 |
|
259 |
Fail if they are not precisely equal.
|
|
260 |
"""
|
|
261 |
extras = [] |
|
262 |
shape = list(shape) # copy |
|
263 |
for path, ie in inv.entries(): |
|
264 |
name = path.replace('\\', '/') |
|
265 |
if ie.kind == 'dir': |
|
266 |
name = name + '/' |
|
267 |
if name in shape: |
|
268 |
shape.remove(name) |
|
269 |
else: |
|
270 |
extras.append(name) |
|
271 |
if shape: |
|
272 |
self.fail("expected paths not found in inventory: %r" % shape) |
|
273 |
if extras: |
|
274 |
self.fail("unexpected paths found in inventory: %r" % extras) |
|
275 |
||
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
276 |
def apply_redirected(self, stdin=None, stdout=None, stderr=None, |
277 |
a_callable=None, *args, **kwargs): |
|
278 |
"""Call callable with redirected std io pipes.
|
|
279 |
||
280 |
Returns the return code."""
|
|
281 |
if not callable(a_callable): |
|
282 |
raise ValueError("a_callable must be callable.") |
|
283 |
if stdin is None: |
|
284 |
stdin = StringIO("") |
|
285 |
if stdout is None: |
|
974.1.70
by Aaron Bentley
Fixed selftest spewage (Brian M. Carlson) |
286 |
if hasattr(self, "_log_file"): |
287 |
stdout = self._log_file |
|
288 |
else: |
|
289 |
stdout = StringIO() |
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
290 |
if stderr is None: |
974.1.70
by Aaron Bentley
Fixed selftest spewage (Brian M. Carlson) |
291 |
if hasattr(self, "_log_file"): |
292 |
stderr = self._log_file |
|
293 |
else: |
|
294 |
stderr = StringIO() |
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
295 |
real_stdin = sys.stdin |
296 |
real_stdout = sys.stdout |
|
297 |
real_stderr = sys.stderr |
|
298 |
try: |
|
299 |
sys.stdout = stdout |
|
300 |
sys.stderr = stderr |
|
301 |
sys.stdin = stdin |
|
1160
by Martin Pool
- tiny refactoring |
302 |
return a_callable(*args, **kwargs) |
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
303 |
finally: |
304 |
sys.stdout = real_stdout |
|
305 |
sys.stderr = real_stderr |
|
306 |
sys.stdin = real_stdin |
|
307 |
||
308 |
||
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
309 |
BzrTestBase = TestCase |
310 |
||
311 |
||
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
312 |
class TestCaseInTempDir(TestCase): |
313 |
"""Derived class that runs a test within a temporary directory.
|
|
314 |
||
315 |
This is useful for tests that need to create a branch, etc.
|
|
316 |
||
317 |
The directory is created in a slightly complex way: for each
|
|
318 |
Python invocation, a new temporary top-level directory is created.
|
|
319 |
All test cases create their own directory within that. If the
|
|
320 |
tests complete successfully, the directory is removed.
|
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
321 |
|
322 |
InTempDir is an old alias for FunctionalTestCase.
|
|
323 |
"""
|
|
324 |
||
325 |
TEST_ROOT = None |
|
326 |
_TEST_NAME = 'test' |
|
327 |
OVERRIDE_PYTHON = 'python' |
|
328 |
||
329 |
def check_file_contents(self, filename, expect): |
|
330 |
self.log("check contents of file %s" % filename) |
|
331 |
contents = file(filename, 'r').read() |
|
332 |
if contents != expect: |
|
333 |
self.log("expected: %r" % expect) |
|
334 |
self.log("actually: %r" % contents) |
|
1185.1.41
by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid |
335 |
self.fail("contents of %s not as expected" % filename) |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
336 |
|
337 |
def _make_test_root(self): |
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
338 |
if TestCaseInTempDir.TEST_ROOT is not None: |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
339 |
return
|
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
340 |
i = 0 |
341 |
while True: |
|
342 |
root = 'test%04d.tmp' % i |
|
343 |
try: |
|
344 |
os.mkdir(root) |
|
345 |
except OSError, e: |
|
346 |
if e.errno == errno.EEXIST: |
|
347 |
i += 1 |
|
348 |
continue
|
|
349 |
else: |
|
350 |
raise
|
|
351 |
# successfully created
|
|
352 |
TestCaseInTempDir.TEST_ROOT = os.path.abspath(root) |
|
353 |
break
|
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
354 |
# make a fake bzr directory there to prevent any tests propagating
|
355 |
# up onto the source directory's real branch
|
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
356 |
os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr')) |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
357 |
|
358 |
def setUp(self): |
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
359 |
super(TestCaseInTempDir, self).setUp() |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
360 |
self._make_test_root() |
361 |
self._currentdir = os.getcwdu() |
|
1218
by Martin Pool
- fix up import |
362 |
short_id = self.id().replace('bzrlib.selftest.', '') \ |
363 |
.replace('__main__.', '') |
|
1212
by Martin Pool
- use shorter test directory names |
364 |
self.test_dir = os.path.join(self.TEST_ROOT, short_id) |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
365 |
os.mkdir(self.test_dir) |
366 |
os.chdir(self.test_dir) |
|
367 |
||
368 |
def tearDown(self): |
|
369 |
os.chdir(self._currentdir) |
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
370 |
super(TestCaseInTempDir, self).tearDown() |
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
371 |
|
372 |
def build_tree(self, shape): |
|
373 |
"""Build a test tree according to a pattern.
|
|
374 |
||
375 |
shape is a sequence of file specifications. If the final
|
|
376 |
character is '/', a directory is created.
|
|
377 |
||
378 |
This doesn't add anything to a branch.
|
|
379 |
"""
|
|
380 |
# XXX: It's OK to just create them using forward slashes on windows?
|
|
381 |
for name in shape: |
|
382 |
assert isinstance(name, basestring) |
|
383 |
if name[-1] == '/': |
|
384 |
os.mkdir(name[:-1]) |
|
385 |
else: |
|
386 |
f = file(name, 'wt') |
|
387 |
print >>f, "contents of", name |
|
388 |
f.close() |
|
389 |
||
390 |
||
391 |
class MetaTestLog(TestCase): |
|
392 |
def test_logging(self): |
|
393 |
"""Test logs are captured when a test fails."""
|
|
394 |
logging.info('an info message') |
|
395 |
warning('something looks dodgy...') |
|
396 |
logging.debug('hello, test is running') |
|
397 |
##assert 0
|
|
398 |
||
399 |
||
1393.1.6
by Martin Pool
- fold testsweet into bzrlib.selftest |
400 |
|
401 |
def run_suite(suite, name='test', verbose=False, pattern=".*"): |
|
402 |
TestCaseInTempDir._TEST_NAME = name |
|
403 |
if verbose: |
|
404 |
verbosity = 2 |
|
405 |
else: |
|
406 |
verbosity = 1 |
|
407 |
runner = TextTestRunner(stream=sys.stdout, |
|
408 |
descriptions=0, |
|
409 |
verbosity=verbosity) |
|
410 |
visitor = filteringVisitor(pattern) |
|
411 |
suite.visit(visitor) |
|
412 |
result = runner.run(visitor.suite()) |
|
413 |
# This is still a little bogus,
|
|
414 |
# but only a little. Folk not using our testrunner will
|
|
415 |
# have to delete their temp directories themselves.
|
|
416 |
if result.wasSuccessful(): |
|
417 |
if TestCaseInTempDir.TEST_ROOT is not None: |
|
418 |
shutil.rmtree(TestCaseInTempDir.TEST_ROOT) |
|
419 |
else: |
|
420 |
print "Failed tests working directories are in '%s'\n" % TestCaseInTempDir.TEST_ROOT |
|
421 |
return result.wasSuccessful() |
|
422 |
||
423 |
||
1092.1.20
by Robert Collins
import and use TestUtil to do regex based partial test runs |
424 |
def selftest(verbose=False, pattern=".*"): |
1204
by Martin Pool
doc |
425 |
"""Run the whole test suite under the enhanced runner"""
|
1393.1.6
by Martin Pool
- fold testsweet into bzrlib.selftest |
426 |
return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern) |
1092.1.17
by Robert Collins
remove TEST_CLASSES dead code and provide a bzrlib.test_suite() convenience method |
427 |
|
428 |
||
429 |
def test_suite(): |
|
1204
by Martin Pool
doc |
430 |
"""Build and return TestSuite for the whole program."""
|
1393.1.6
by Martin Pool
- fold testsweet into bzrlib.selftest |
431 |
import bzrlib.store, bzrlib.inventory, bzrlib.branch |
432 |
import bzrlib.osutils, bzrlib.merge3, bzrlib.plugin |
|
721
by Martin Pool
- framework for running external commands from unittest suite |
433 |
from doctest import DocTestSuite |
434 |
||
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
435 |
global MODULES_TO_TEST, MODULES_TO_DOCTEST |
436 |
||
437 |
testmod_names = \ |
|
1123
by Martin Pool
* move bzr-specific code from testsweet into bzrlib.selftest |
438 |
['bzrlib.selftest.MetaTestLog', |
439 |
'bzrlib.selftest.testinv', |
|
1390
by Robert Collins
pair programming worx... merge integration and weave |
440 |
'bzrlib.selftest.test_ancestry', |
1251
by Martin Pool
- fix up commit in directory with some deleted files |
441 |
'bzrlib.selftest.test_commit', |
1342
by Martin Pool
- start some tests for commit of merge revisions |
442 |
'bzrlib.selftest.test_commit_merge', |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
443 |
'bzrlib.selftest.versioning', |
444 |
'bzrlib.selftest.testmerge3', |
|
974.1.80
by Aaron Bentley
Improved merge error handling and testing |
445 |
'bzrlib.selftest.testmerge', |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
446 |
'bzrlib.selftest.testhashcache', |
447 |
'bzrlib.selftest.teststatus', |
|
448 |
'bzrlib.selftest.testlog', |
|
449 |
'bzrlib.selftest.testrevisionnamespaces', |
|
450 |
'bzrlib.selftest.testbranch', |
|
1270
by Martin Pool
- fix recording of merged ancestry lines |
451 |
'bzrlib.selftest.testrevision', |
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
452 |
'bzrlib.selftest.test_revision_info', |
1277
by Martin Pool
- turn on merge_core tests again |
453 |
'bzrlib.selftest.test_merge_core', |
1092.1.26
by Robert Collins
start writing star-topology test, realise we need smart-add change |
454 |
'bzrlib.selftest.test_smart_add', |
1185.3.29
by John Arbash Meinel
Added test cases for handling bogus files. |
455 |
'bzrlib.selftest.test_bad_files', |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
456 |
'bzrlib.selftest.testdiff', |
1273
by Martin Pool
- fix up copy_branch, etc |
457 |
'bzrlib.selftest.test_parent', |
1181
by Martin Pool
- add test for deserialization from a canned XML inventory |
458 |
'bzrlib.selftest.test_xml', |
1234
by Martin Pool
- run weave tests from bzr selftest |
459 |
'bzrlib.selftest.test_weave', |
1274
by Martin Pool
- stub out obsolete fetch tests |
460 |
'bzrlib.selftest.testfetch', |
1281
by Martin Pool
- reenable whitebox tests |
461 |
'bzrlib.selftest.whitebox', |
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
462 |
'bzrlib.selftest.teststore', |
1288
by Martin Pool
- reenable blackbox tests - everything passes! |
463 |
'bzrlib.selftest.blackbox', |
1185.11.1
by John Arbash Meinel
(broken) Transport work is merged in. Tests do not pass yet. |
464 |
'bzrlib.selftest.testtransport', |
974.1.57
by aaron.bentley at utoronto
Started work on djkstra longest-path algorithm |
465 |
'bzrlib.selftest.testgraph', |
1399.1.2
by Robert Collins
push kind character creation into InventoryEntry and TreeEntry |
466 |
'bzrlib.selftest.testworkingtree', |
1393.1.31
by Martin Pool
- add simple test for upgrade |
467 |
'bzrlib.selftest.test_upgrade', |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
468 |
]
|
469 |
||
855
by Martin Pool
- Patch from John to allow plugins to add their own tests. |
470 |
for m in (bzrlib.store, bzrlib.inventory, bzrlib.branch, |
471 |
bzrlib.osutils, bzrlib.commands, bzrlib.merge3): |
|
472 |
if m not in MODULES_TO_DOCTEST: |
|
473 |
MODULES_TO_DOCTEST.append(m) |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
474 |
|
1102
by Martin Pool
- merge test refactoring from robertc |
475 |
TestCase.BZRPATH = os.path.join(os.path.realpath(os.path.dirname(bzrlib.__path__[0])), 'bzr') |
476 |
print '%-30s %s' % ('bzr binary', TestCase.BZRPATH) |
|
744
by Martin Pool
- show nicer descriptions while running tests |
477 |
print
|
721
by Martin Pool
- framework for running external commands from unittest suite |
478 |
suite = TestSuite() |
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
479 |
suite.addTest(TestLoader().loadTestsFromNames(testmod_names)) |
855
by Martin Pool
- Patch from John to allow plugins to add their own tests. |
480 |
for m in MODULES_TO_TEST: |
481 |
suite.addTest(TestLoader().loadTestsFromModule(m)) |
|
482 |
for m in (MODULES_TO_DOCTEST): |
|
721
by Martin Pool
- framework for running external commands from unittest suite |
483 |
suite.addTest(DocTestSuite(m)) |
908
by Martin Pool
- merge john's plugins-have-test_suite.patch: |
484 |
for p in bzrlib.plugin.all_plugins: |
485 |
if hasattr(p, 'test_suite'): |
|
486 |
suite.addTest(p.test_suite()) |
|
1092.1.17
by Robert Collins
remove TEST_CLASSES dead code and provide a bzrlib.test_suite() convenience method |
487 |
return suite |
764
by Martin Pool
- log messages from a particular test are printed if that test fails |
488 |