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

Rick Foos rfoos at codeaurora.org
Tue Apr 21 15:16:05 PDT 2015


Author: rfoos
Date: Tue Apr 21 17:16:05 2015
New Revision: 235449

URL: http://llvm.org/viewvc/llvm-project?rev=235449&view=rev
Log:
[zorg] LitTestCommand aborts if Verbose log line is not preceded by a valid test status line.

Summary:
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 mismatched status/log lines skips the log entry.

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

Test Plan: Unit test 'test_missing_lastresult' shows the before and after effects of the change.

Reviewers: gkistanova

Reviewed By: gkistanova

Subscribers: llvm-commits

Projects: #zorg

Differential Revision: http://reviews.llvm.org/D9091

Modified:
    zorg/trunk/zorg/buildbot/commands/LitTestCommand.py

Modified: zorg/trunk/zorg/buildbot/commands/LitTestCommand.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/commands/LitTestCommand.py?rev=235449&r1=235448&r2=235449&view=diff
==============================================================================
--- zorg/trunk/zorg/buildbot/commands/LitTestCommand.py (original)
+++ zorg/trunk/zorg/buildbot/commands/LitTestCommand.py Tue Apr 21 17:16:05 2015
@@ -53,24 +53,29 @@ class LitLogObserver(LogLineObserver):
 
   def testInfoFinished(self):
     # We have finished getting information for one test, handle it.
-    code, name = self.lastTestResult
+    if self.lastTestResult:
+        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 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
+    else:
+        if self.activeVerboseLog:
+            self.activeVerboseLog.append(
+              "error: missing test status line, skipping log")
 
     # Reset the current state.
     self.lastTestResult = None
@@ -101,7 +106,11 @@ class LitLogObserver(LogLineObserver):
     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:
+            self.activeVerboseLog.append(
+              "error: missing test line before verbose log start.")
+      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 @@ TIMEOUT: test-four (4 of 4)
     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)





More information about the llvm-commits mailing list