[PATCH] Fix the problem that the last test failure not always displayed on test summary page for LitTestCommand

Ying Chen chying at google.com
Wed Mar 11 18:41:53 PDT 2015


As suggested by Siva, change variable/function name for readability

- Change from summaryLineReceived to handleSimplifiedLogLine as opposed to handleVerboseLogLine
- Change from summaryLine to simplifiedLog


http://reviews.llvm.org/D8229

Files:
  zorg/buildbot/commands/LitTestCommand.py

Index: zorg/buildbot/commands/LitTestCommand.py
===================================================================
--- zorg/buildbot/commands/LitTestCommand.py
+++ zorg/buildbot/commands/LitTestCommand.py
@@ -36,6 +36,7 @@
     self.activeVerboseLog = None
     # Current line will be parsed as result steps only if parserStarted is True
     self.parserStarted = not parseSummaryOnly
+    self.simplifiedLog = False
 
   def hadFailure(self):
     for code in self.failingCodes:
@@ -67,15 +68,29 @@
       # Otherwise, we run out of the allowed name length on some hosts.
       name_part = name.rpartition('::')
       self.step.addCompleteLog(
-                  name_part[0].strip() + name_part[1] + basename(name_part[2]),
+                  code + ': ' + name_part[0].strip() + name_part[1] + basename(name_part[2]),
                   '\n'.join(self.activeVerboseLog))
       self.numLogs += 1
 
     # Reset the current state.
     self.lastTestResult = None
     self.activeVerboseLog = None
 
+  def handleSimplifiedLogLine(self, line):
+    # Check for test status line
+    m = self.kTestLineRE.match(line.strip())
+    if m:
+      # Remember the last test result and update the result counts.
+      self.lastTestResult = (code, name) = m.groups()
+      self.resultCounts[code] = self.resultCounts.get(code, 0) + 1
+      self.testInfoFinished()
+    return
+
   def outLineReceived(self, line):
+    # Assert - Lines after "Failing Test (\d)" will be summary line and will not contain verbose message
+    if self.simplifiedLog is True:
+      self.handleSimplifiedLogLine(line)
+      return
     # If we are inside a verbose log, just accumulate lines until we reach the
     # stop marker.
     if self.activeVerboseLog is not None:
@@ -103,6 +118,7 @@
 
     if self.kStartSummaryRE.match(line):
       self.parserStarted = True;
+      self.simplifiedLog = True;
 
     #Assign result line only if summary marker has been matched
     #Or if all lines should be parsed
@@ -188,7 +204,7 @@
 """)
 
     self.assertEqual(obs.resultCounts, { 'FAIL' : 1, 'PASS' : 2 })
-    self.assertEqual(obs.step.logs, [('test-two', 'FAIL: test-two')])
+    self.assertEqual(obs.step.logs, [('FAIL: test-two', 'FAIL: test-two')])
 
   def test_verbose_logs(self):
     obs = self.parse_log("""
@@ -202,12 +218,12 @@
 
     self.assertEqual(obs.resultCounts, { 'FAIL' : 3 })
     self.assertEqual(obs.step.logs, [
-        ('test-one', 'FAIL: test-one'),
-        ('test-two', """\
+        ('FAIL: test-one', 'FAIL: test-one'),
+        ('FAIL: test-two', """\
 **** TEST 'test-two' FAILED ****
 bla bla bla
 **********"""),
-        ('test-three', 'FAIL: test-three')])
+        ('FAIL: test-three', 'FAIL: test-three')])
 
 class TestCommand(unittest.TestCase):
   def parse_log(self, text, **kwargs):
@@ -233,7 +249,7 @@
 FAIL: test-one (1 of 2)
 FAIL: test-two (2 of 2)
 """, max_logs=1)
-    self.assertEqual(cmd.logObserver.step.logs, [('test-one', 'FAIL: test-one')])
+    self.assertEqual(cmd.logObserver.step.logs, [('FAIL: test-one', 'FAIL: test-one')])
 
 if __name__ == '__main__':
   unittest.main()

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8229.21796.patch
Type: text/x-patch
Size: 3118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150312/acb0d26a/attachment.bin>


More information about the llvm-commits mailing list