summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-13 21:17:05 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-09-14 10:54:27 +0200
commitfb1c96665201a8090bcf14db7a71a752e4cd7041 (patch)
tree4d536f60b2119f7b180c2b10e44cc1a0aaff89bf /selftest
parent8530d5afdee8fbc4d87398839d37c503dc05410d (diff)
downloadsamba-fb1c96665201a8090bcf14db7a71a752e4cd7041.tar.gz
samba-fb1c96665201a8090bcf14db7a71a752e4cd7041.tar.bz2
samba-fb1c96665201a8090bcf14db7a71a752e4cd7041.zip
subunit: Use standard subunit test protocol client, use standard name for startTest.
Diffstat (limited to 'selftest')
-rwxr-xr-xselftest/filter-subunit3
-rwxr-xr-xselftest/format-subunit4
-rw-r--r--selftest/subunithelper.py44
3 files changed, 27 insertions, 24 deletions
diff --git a/selftest/filter-subunit b/selftest/filter-subunit
index 923d5cf3a3..f5ab660350 100755
--- a/selftest/filter-subunit
+++ b/selftest/filter-subunit
@@ -43,7 +43,8 @@ def handle_sigint(sig, stack):
sys.exit(0)
signal.signal(signal.SIGINT, handle_sigint)
-msg_ops = subunithelper.FilterOps(opts.prefix, expected_failures,
+out = subunithelper.SubunitOps(sys.stdout)
+msg_ops = subunithelper.FilterOps(out, opts.prefix, expected_failures,
opts.strip_passed_output)
sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))
diff --git a/selftest/format-subunit b/selftest/format-subunit
index 31136b05ff..ff57b54ace 100755
--- a/selftest/format-subunit
+++ b/selftest/format-subunit
@@ -28,7 +28,7 @@ def format_time(t):
return ret
-class PlainFormatter(testtools.testresult.TestResult):
+class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
def __init__(self, summaryfile, verbose, immediate, statistics,
totaltests=None):
@@ -122,7 +122,7 @@ class PlainFormatter(testtools.testresult.TestResult):
sys.stdout.write(out)
- def start_test(self, testname):
+ def startTest(self, testname):
pass
def end_test(self, testname, result, unexpected, reason=None):
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index 11b581f6f1..f15db87d9e 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -25,6 +25,12 @@ import time
VALID_RESULTS = ['success', 'successful', 'failure', 'fail', 'skip', 'knownfail', 'error', 'xfail', 'skip-testsuite', 'testsuite-failure', 'testsuite-xfail', 'testsuite-success', 'testsuite-error']
+class TestsuiteEnabledTestResult(testtools.testresult.TestResult):
+
+ def start_testsuite(self, name):
+ raise NotImplementedError(self.start_testsuite)
+
+
def parse_results(msg_ops, statistics, fh):
expected_fail = 0
open_tests = []
@@ -41,7 +47,7 @@ def parse_results(msg_ops, statistics, fh):
arg = parts[1]
if command in ("test", "testing"):
msg_ops.control_msg(l)
- msg_ops.start_test(arg.rstrip())
+ msg_ops.startTest(arg.rstrip())
open_tests.append(arg.rstrip())
elif command == "time":
msg_ops.control_msg(l)
@@ -166,18 +172,16 @@ def parse_results(msg_ops, statistics, fh):
return 0
-class SubunitOps(object):
+class SubunitOps(subunit.TestProtocolClient,TestsuiteEnabledTestResult):
- def start_test(self, testname):
- print "test: %s" % testname
+ def startTest(self, testname):
+ self._stream.write("test: %s\n" % testname)
def end_test(self, name, result, reason=None):
if reason:
- print "%s: %s [" % (result, name)
- print reason
- print "]"
+ self._stream.write("%s: %s [\n%s\n]\n" % (result, name, reason))
else:
- print "%s: %s" % (result, name)
+ self._stream.write("%s: %s\n" % (result, name))
def skip_test(self, name, reason=None):
self.end_test(name, "skip", reason)
@@ -193,7 +197,7 @@ class SubunitOps(object):
def report_time(self, t):
(year, mon, mday, hour, min, sec, wday, yday, isdst) = time.localtime(t)
- print "time: %04d-%02d-%02d %02d:%02d:%02d" % (year, mon, mday, hour, min, sec)
+ self._stream.write("time: %04d-%02d-%02d %02d:%02d:%02d\n" % (year, mon, mday, hour, min, sec))
def progress(self, offset, whence):
if whence == subunit.PROGRESS_CUR and offset > -1:
@@ -206,25 +210,23 @@ class SubunitOps(object):
offset = "pop"
else:
prefix = ""
- print "progress: %s%s" % (prefix, offset)
+ self._stream.write("progress: %s%s\n" % (prefix, offset))
# The following are Samba extensions:
def start_testsuite(self, name):
- print "testsuite: %s" % name
+ self._stream.write("testsuite: %s\n" % name)
def skip_testsuite(self, name, reason=None):
if reason:
- print "skip-testsuite: %s [\n%s\n]" % (name, reason)
+ self._stream.write("skip-testsuite: %s [\n%s\n]\n" % (name, reason))
else:
- print "skip-testsuite: %s" % name
+ self._stream.write("skip-testsuite: %s\n" % name)
def end_testsuite(self, name, result, reason=None):
if reason:
- print "testsuite-%s: %s [" % (result, name)
- print "%s" % reason
- print "]"
+ self._stream.write("testsuite-%s: %s [\n%s\n]\n" % (result, name, reason))
else:
- print "testsuite-%s: %s" % (result, name)
+ self._stream.write("testsuite-%s: %s\n" % (result, name))
def read_test_regexes(name):
@@ -271,14 +273,14 @@ class FilterOps(testtools.testresult.TestResult):
else:
self.output+=msg
- def start_test(self, testname):
+ def startTest(self, testname):
if self.prefix is not None:
testname = self.prefix + testname
if self.strip_ok_output:
self.output = ""
- self._ops.start_test(testname)
+ self._ops.startTest(testname)
def end_test(self, testname, result, unexpected, reason):
if self.prefix is not None:
@@ -345,8 +347,8 @@ class FilterOps(testtools.testresult.TestResult):
self._ops.end_testsuite(name, result, reason)
- def __init__(self, prefix, expected_failures, strip_ok_output):
- self._ops = SubunitOps()
+ def __init__(self, out, prefix, expected_failures, strip_ok_output):
+ self._ops = out
self.output = None
self.prefix = prefix
self.expected_failures = expected_failures