Bug 1278466 - mozunit: Avoid IndexError in printFail when the message is empty. r?gps draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 07 Jun 2016 15:15:53 +0900
changeset 376066 fee8a58381fc8362e206e27bca0c7b2b99887c7c
parent 375911 aa8cdba912d328070bf56330a3abe5b86e9cd136
child 523077 46b0a1906b75182ba4bdb59fb3359899f9e38bb7
push id20498
push userbmo:mh+mozilla@glandium.org
push dateTue, 07 Jun 2016 11:13:51 +0000
reviewersgps
bugs1278466
milestone49.0a1
Bug 1278466 - mozunit: Avoid IndexError in printFail when the message is empty. r?gps ''.splitlines() returns [], not ['']. So when the message is empty, we currently fail with IndexError when trying to get the first line in the message.
config/mozunit.py
--- a/config/mozunit.py
+++ b/config/mozunit.py
@@ -68,17 +68,19 @@ class _MozTestResult(_TestResult):
     def addFailure(self, test, err):
         _TestResult.addFailure(self, test, err)
         self.printFail(test,err)
         self.stream.writeln("FAIL: {0}".format(self.getDescription(test)))
         self.stream.writeln(self.failures[-1][1])
 
     def printFail(self, test, err):
         exctype, value, tb = err
-        message = value.message.splitlines()[0]
+        message = value.message
+        if message:
+            message = message.splitlines()[0]
         # Skip test runner traceback levels
         while tb and self._is_relevant_tb_level(tb):
             tb = tb.tb_next
         if tb:
             _, ln, _ = inspect.getframeinfo(tb)[:3]
             message = 'line {0}: {1}'.format(ln, message)
         self.printStatus("TEST-UNEXPECTED-FAIL", test, message)