[PATCH] [zorg] LitTestCommand aborts if Verbose log line is not preceded by a valid test status line.

Rick Foos rfoos at codeaurora.org
Fri Apr 17 16:17:42 PDT 2015


Lit expects a test status line (kTestLineRE) before a verbose log start marker (kTestVerboseLogStartRE).

FAIL: LLDB :: asdf (9 of 20)
*** TEST 'LLDB :: asdf' FAIL ***

If the test status line is malformed, LitTestCommand has an exception at outLineReceived, and testInfoFinished because lastTestResult is None.

FAIL: LLDB :: asdf
*** TEST 'LLDB :: asdf' FAIL ***

Another case of bad status/log lines skips the log entry.

This patch handles lastTestResult is None, and skips the log entry.

http://reviews.llvm.org/D9091

Files:
  zorg/buildbot/commands/LitTestCommand.py

Index: zorg/buildbot/commands/LitTestCommand.py
===================================================================
--- zorg/buildbot/commands/LitTestCommand.py
+++ zorg/buildbot/commands/LitTestCommand.py
@@ -53,24 +53,29 @@
 
   def testInfoFinished(self):
     # We have finished getting information for one test, handle it.
-    code, name = self.lastTestResult
-
-    # If the test failed, add a log entry for it (unless we have reached the
-    # max).
-    if code in self.failingCodes and (self.maxLogs is None or
-                                      self.numLogs < self.maxLogs):
-      # If a verbose log was not provided, just add a one line description.
-      if self.activeVerboseLog is None:
-        self.activeVerboseLog = ['%s: %s' % (code, name)]
-
-      # Add the log to the build status.
-      # Make the test name short, the qualified test name is in the log anyway.
-      # Otherwise, we run out of the allowed name length on some hosts.
-      name_part = name.rpartition('::')
-      self.step.addCompleteLog(
-                  code + ': ' + name_part[0].strip() + name_part[1] + basename(name_part[2]),
-                  '\n'.join(self.activeVerboseLog))
-      self.numLogs += 1
+    if self.lastTestResult is None:
+        if self.activeVerboseLog is not None:
+            self.activeVerboseLog.append(
+              "error: missing test status line, skipping log")
+    else:
+        code, name = self.lastTestResult
+
+        # If the test failed, add a log entry for it (unless we have reached the
+        # max).
+        if code in self.failingCodes and (self.maxLogs is None or
+                                          self.numLogs < self.maxLogs):
+          # If a verbose log was not provided, just add a one line description.
+          if self.activeVerboseLog is None:
+            self.activeVerboseLog = ['%s: %s' % (code, name)]
+
+          # Add the log to the build status.
+          # Make the test name short, the qualified test name is in the log anyway.
+          # Otherwise, we run out of the allowed name length on some hosts.
+          name_part = name.rpartition('::')
+          self.step.addCompleteLog(
+                      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
@@ -101,7 +106,11 @@
     m = self.kTestVerboseLogStartRE.match(line.strip())
     if m:
       self.activeVerboseLog = [line]
-      if m.group(1) != self.lastTestResult[1]:
+      if self.lastTestResult is None:
+        if self.activeVerboseLog is not None:
+            self.activeVerboseLog.append(
+              "error: missing test name for \'%s\'" % m.group(1))
+      elif m.group(1) != self.lastTestResult[1]:
         # This is bogus, the verbose log test name doesn't match what we
         # expect. Just note it in the log but otherwise accumulate as normal.
         self.activeVerboseLog.append(
@@ -208,6 +217,20 @@
     self.assertEqual(obs.resultCounts, { 'FAIL' : 1, 'TIMEOUT' : 1, 'PASS' : 2 })
     self.assertEqual(obs.step.logs, [('FAIL: test-two', 'FAIL: test-two'), ('TIMEOUT: test-four', 'TIMEOUT: test-four')])
 
+  def test_missing_lastresult(self):
+    obs = self.parse_log("""
+FAIL: LLDB :: 10-breakpoint-by-address-multiple-hit-first-add-next
+********** TEST 'LLDB :: 10-breakpoint-by-address-multiple-hit-first-add-next' FAIL **********
+bla bla bla
+**********
+         TIMEOUT: LLDB :: 57-dlopen-breakpoint (51 of 57)
+         ********** TEST 'LLDB :: 57-dlopen-breakpoint' TIMEOUT **********
+         bla
+         **********
+""")
+
+    self.assertEqual(obs.resultCounts, {'TIMEOUT': 1})
+
   def test_verbose_logs(self):
     obs = self.parse_log("""
 FAIL: test-one (1 of 3)

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9091.23972.patch
Type: text/x-patch
Size: 3852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150417/ed3818c3/attachment.bin>


More information about the llvm-commits mailing list