[Buildbot-commits] buildbot/buildbot/process step_twisted.py, 1.79, 1.80

Brian Warner warner at users.sourceforge.net
Thu Jun 15 05:47:50 UTC 2006


Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30765/buildbot/process

Modified Files:
	step_twisted.py 
Log Message:
[project @ implement TrialTestCaseCounter, a LogObserver that counts test cases run]

Original author: warner at lothar.com
Date: 2006-06-15 01:29:02

Index: step_twisted.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/step_twisted.py,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- step_twisted.py	15 Jun 2006 05:47:42 -0000	1.79
+++ step_twisted.py	15 Jun 2006 05:47:48 -0000	1.80
@@ -2,6 +2,7 @@
 
 from twisted.python import log, failure
 
+from buildbot import interfaces
 from buildbot.status import tests, builder
 from buildbot.status.builder import SUCCESS, FAILURE, WARNINGS, SKIPPED
 from buildbot.process import step
@@ -130,6 +131,33 @@
 
     return res
 
+
+class TrialTestCaseCounter(step.LogLineObserver):
+    _line_re = re.compile(r'^([\w\.]+) \.\.\. \[([^\]]+)\]$')
+    numTests = 0
+    finished = False
+
+    def outLineReceived(self, line):
+        # different versions of Twisted emit different per-test lines with
+        # the bwverbose reporter.
+        #  2.0.0: testSlave (buildbot.test.test_runner.Create) ... [OK]
+        #  2.1.0: buildbot.test.test_runner.Create.testSlave ... [OK]
+        #  2.4.0: buildbot.test.test_runner.Create.testSlave ... [OK]
+        # Let's just handle the most recent version, since it's the easiest.
+
+        if self.finished:
+            return
+        if line.startswith("=" * 40):
+            self.finished = True
+            return
+
+        m = self._line_re.search(line.strip())
+        if m:
+            testname, result = m.groups()
+            self.numTests += 1
+            self.step.setProgress('tests', self.numTests)
+
+
 UNSPECIFIED=() # since None is a valid choice
 
 class Trial(ShellCommand):
@@ -202,6 +230,7 @@
     """
 
     name = "trial"
+    progressMetrics = ('output', 'tests')
 
     flunkOnFailure = True
     python = None
@@ -370,6 +399,10 @@
             self.description = ["testing"]
             self.descriptionDone = ["tests"]
 
+        # this counter will feed Progress along the 'test cases' metric
+        counter = TrialTestCaseCounter()
+        self.addLogObserver('stdio', counter)
+
     def setupEnvironment(self, cmd):
         ShellCommand.setupEnvironment(self, cmd)
         if self.testpath != None:
@@ -406,6 +439,7 @@
         log.msg("Trial.start: command is", self.command)
         ShellCommand.start(self)
 
+
     def _commandComplete(self, cmd):
         # before doing the summary, etc, fetch _trial_temp/test.log
         # TODO: refactor ShellCommand so I don't have to override such





More information about the Commits mailing list