[Buildbot-commits] buildbot/buildbot/steps shell.py,1.26,1.27

Brian Warner warner at users.sourceforge.net
Mon Jul 21 17:52:18 UTC 2008


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

Modified Files:
	shell.py 
Log Message:
[project @ #228:pmt-use-stats.patch]
Use statistics in the PerlModuleTest, and move the test-display getText method
to the Test class.

Original author: dustin at v.igoro.us
Date: 2008-07-21 15:00:17+00:00

Index: shell.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/steps/shell.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- shell.py	27 May 2008 00:52:29 -0000	1.26
+++ shell.py	21 Jul 2008 17:52:16 -0000	1.27
@@ -322,6 +322,9 @@
         if self.warnCount:
             self.addCompleteLog("warnings", "\n".join(warnings) + "\n")
 
+        warnings_stat = self.step_status.getStatistic('warnings', 0)
+        self.step_status.setStatistic('warnings', warnings_stat + self.warnCount)
+
         try:
             old_count = self.getProperty("warnings-count")
         except KeyError:
@@ -363,6 +366,36 @@
     descriptionDone = ["test"]
     command = ["make", "test"]
 
+    def setTestResults(self, total=0, failed=0, passed=0, warnings=0):
+        """
+        Called by subclasses to set the relevant statistics; this actually
+        adds to any statistics already present
+        """
+        total += self.step_status.getStatistic('total', 0)
+        self.step_status.setStatistic('total', total)
+        failed += self.step_status.getStatistic('failed', 0)
+        self.step_status.setStatistic('failed', failed)
+        warnings += self.step_status.getStatistic('warnings', 0)
+        self.step_status.setStatistic('warnings', warnings)
+        passed += self.step_status.getStatistic('passed', 0)
+        self.step_status.setStatistic('passed', passed)
+
+    def getText(self, cmd, results):
+        if self.step_status.hasStatistic('total'):
+            total, failed, passed, warnings = \
+                [ self.step_status.getStatistic(n,0)
+                  for n in 'total', 'failed', 'passed', 'warnings' ]
+            if not total: total = failed + passed + warnings
+
+            rv = []
+            if total: rv.append('%d tests' % total)
+            if passed: rv.append('%d passed' % passed)
+            if warnings: rv.append('%d warnings' % warnings)
+            if failed: rv.append('%d failed' % failed)
+            return rv
+        else:
+            return [ "no test results" ]
+
 class PerlModuleTest(Test):
     command=["prove", "--lib", "lib", "-r", "t"]
     total = 0
@@ -400,19 +433,6 @@
         total = int(total_str)
         passed = total - failed
 
-        self.total, self.failed, self.passed = total, failed, passed
-
-        self.setProperty('tests-total', total, "PerlModuleTest")
-        self.setProperty('tests-failed', failed, "PerlModuleTest")
-        self.setProperty('tests-passed', passed, "PerlModuleTest")
-
-        self.warnings = failed
+        self.setTestResults(total=total, failed=failed, passed=passed)
 
         return rc
-
-    def getText(self, cmd, results):
-        if self.total:
-            return [ "%d failed, %d passed" % (self.failed, self.passed) ]
-        else:
-            return [ "no results" ]
-





More information about the Commits mailing list