[Pkg-bazaar-commits] ./bzr/unstable r965: - selftest is less verbose by default, and takes a -v option if you want it
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:21:37 UTC 2009
------------------------------------------------------------
revno: 965
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-07-22 20:31:09 -0300
message:
- selftest is less verbose by default, and takes a -v option if you want it
modified:
bzrlib/commands.py
bzrlib/selftest/__init__.py
testsweet.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-07-22 18:49:46 +0000
+++ b/bzrlib/commands.py 2005-07-22 23:31:09 +0000
@@ -1303,9 +1303,10 @@
class cmd_selftest(Command):
"""Run internal test suite"""
hidden = True
- def run(self):
+ takes_options = ['verbose']
+ def run(self, verbose=False):
from bzrlib.selftest import selftest
- return int(not selftest())
+ return int(not selftest(verbose=verbose))
class cmd_version(Command):
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py 2005-07-22 22:37:53 +0000
+++ b/bzrlib/selftest/__init__.py 2005-07-22 23:31:09 +0000
@@ -20,7 +20,7 @@
MODULES_TO_TEST = []
MODULES_TO_DOCTEST = []
-def selftest():
+def selftest(verbose=False):
from unittest import TestLoader, TestSuite
import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch
import bzrlib.osutils, bzrlib.commands, bzrlib.merge3, bzrlib.plugin
@@ -88,7 +88,7 @@
suite.addTest(unittest.makeSuite(bzrlib.merge_core.MergeTest, 'test_'))
- return run_suite(suite, 'testbzr')
+ return run_suite(suite, 'testbzr', verbose=verbose)
=== modified file 'testsweet.py'
--- a/testsweet.py 2005-07-13 00:30:30 +0000
+++ b/testsweet.py 2005-07-22 23:31:09 +0000
@@ -227,9 +227,12 @@
No special behaviour for now.
"""
- def __init__(self, out):
+ def __init__(self, out, style):
self.out = out
TestResult.__init__(self)
+ assert style in ('none', 'progress', 'verbose')
+ self.style = style
+
def startTest(self, test):
# TODO: Maybe show test.shortDescription somewhere?
@@ -238,32 +241,40 @@
if what == 'runit':
what = test.shortDescription()
- print >>self.out, '%-60.60s' % what,
- self.out.flush()
+ if self.style == 'verbose':
+ print >>self.out, '%-60.60s' % what,
+ self.out.flush()
+ elif self.style == 'progress':
+ self.out.write('~')
+ self.out.flush()
TestResult.startTest(self, test)
+
def stopTest(self, test):
# print
TestResult.stopTest(self, test)
def addError(self, test, err):
- print >>self.out, 'ERROR'
+ if self.style == 'verbose':
+ print >>self.out, 'ERROR'
TestResult.addError(self, test, err)
_show_test_failure('error', test, err, self.out)
def addFailure(self, test, err):
- print >>self.out, 'FAILURE'
+ if self.style == 'verbose':
+ print >>self.out, 'FAILURE'
TestResult.addFailure(self, test, err)
_show_test_failure('failure', test, err, self.out)
def addSuccess(self, test):
- print >>self.out, 'OK'
+ if self.style == 'verbose':
+ print >>self.out, 'OK'
TestResult.addSuccess(self, test)
-def run_suite(suite, name="test"):
+def run_suite(suite, name='test', verbose=False):
import os
import shutil
import time
@@ -278,7 +289,11 @@
real_stderr = sys.stderr
sys.stdout = sys.stderr = TestBase.TEST_LOG
try:
- result = _MyResult(real_stdout)
+ if verbose:
+ style = 'verbose'
+ else:
+ style = 'progress'
+ result = _MyResult(real_stdout, style)
suite.run(result)
finally:
sys.stdout = real_stdout
More information about the Pkg-bazaar-commits
mailing list