selftest: Support parsing progress in format-subunit/filter-subunit.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 30 Mar 2010 12:36:25 +0000 (14:36 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 31 Mar 2010 00:20:08 +0000 (02:20 +0200)
selftest/format-subunit
selftest/subunithelper.py

index f7d09e835c16193c0d2c9d162c7f90312db6f265..eba8c3168245824c6839b183e5f90d8eb0f8ba36 100755 (executable)
@@ -30,6 +30,9 @@ class PlainFormatter(object):
     def testsuite_count(self, count):
         self.totalsuites = count
 
+    def progress(self, offset, whence):
+        pass
+
     def report_time(self, time):
         if self.start_time is None:
             self.start_time = time
index 1a88443391f3d36a7e797331183cc5fb16c3b7fb..36639d94cf106c8d360175766172c46a9eba8088 100644 (file)
@@ -19,6 +19,7 @@ __all__ = ['parse_results']
 
 import re
 import sys
+import subunit
 import time
 
 VALID_RESULTS = ['success', 'successful', 'failure', 'fail', 'skip', 'knownfail', 'error', 'xfail', 'skip-testsuite', 'testsuite-failure', 'testsuite-xfail', 'testsuite-success', 'testsuite-error']
@@ -104,6 +105,16 @@ def parse_results(msg_ops, statistics, fh):
             msg_ops.start_testsuite(l.split(":", 1)[1].strip())
         elif l.startswith("testsuite-count: "):
             msg_ops.testsuite_count(int(l.split(":", 1)[1].strip()))
+        elif l.startswith("progress: "):
+            arg = l.split(":", 1)[1].strip()
+            if arg == "pop":
+                msg_ops.progress(None, subunit.PROGRESS_POP)
+            elif arg == "push":
+                msg_ops.progress(None, subunit.PROGRESS_PUSH)
+            elif arg[0] in '+-':
+                msg_ops.progress(int(arg), subunit.PROGRESS_CUR)
+            else:
+                msg_ops.progress(int(arg), subunit.PROGRESS_SET)
         else:
             msg_ops.output_msg(l)
 
@@ -148,6 +159,19 @@ class SubunitOps(object):
         (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)
 
+    def progress(self, offset, whence):
+        if whence == subunit.PROGRESS_CUR and offset > -1:
+            prefix = "+"
+        elif whence == subunit.PROGRESS_PUSH:
+            prefix = ""
+            offset = "push"
+        elif whence == subunit.PROGRESS_POP:
+            prefix = ""
+            offset = "pop"
+        else:
+            prefix = ""
+        print "progress: %s%s" % (prefix, offset)
+
     # The following are Samba extensions:
     def start_testsuite(self, name):
         print "testsuite: %s" % name
@@ -203,6 +227,9 @@ class FilterOps(object):
     def report_time(self, time):
         self._ops.report_time(time)
 
+    def progress(self, delta, whence):
+        self._ops.progress(delta, whence)
+
     def output_msg(self, msg):
         if self.output is None:
             sys.stdout.write(msg)