Bug 606327 Investigate updating Thunderbird to the latest MozMill 1.5.x - implement support for new 1.5 version, keeping 1.4 backwards compatibility. a=asuth
authorMark Banner <bugzilla@standard8.plus.com>
Thu, 18 Nov 2010 15:54:18 +0000
changeset 6717 38f77a75000d596719a309e4e801524f823ec71f
parent 6716 4c4f1bcda38299e183d7594634733dfcf222d2f6
child 6718 7f98b2c78c31e04ff2c557ef179053e3f8cd7a00
push idunknown
push userunknown
push dateunknown
reviewersasuth
bugs606327
Bug 606327 Investigate updating Thunderbird to the latest MozMill 1.5.x - implement support for new 1.5 version, keeping 1.4 backwards compatibility. a=asuth
mail/test/mozmill/runtest.py
--- a/mail/test/mozmill/runtest.py
+++ b/mail/test/mozmill/runtest.py
@@ -47,16 +47,17 @@ Runs the Bloat test harness
 import sys
 import os, os.path, platform, subprocess, signal
 import shutil
 import mozrunner
 import jsbridge
 import mozmill
 import socket
 import copy
+import simplejson
 SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
 sys.path.append(SCRIPT_DIRECTORY)
 
 from automation import Automation
 automation = Automation()
 
 from automationutils import checkForCrashes
 from time import sleep
@@ -314,20 +315,30 @@ class ThunderTestCLI(mozmill.CLI):
         else:
             try:
                 wrapper = imp.load_module(WRAPPER_MODULE_NAME, fd, path, desc)
             finally:
                 if fd is not None:
                     fd.close()
 
 TEST_RESULTS = []
+# Versions of MozMill prior to 1.5 did not output test-pass /
+# TEST-UNEXPECTED-FAIL. Since 1.5 happened this gets output, so we only want
+# a summary at the end to make it easy for developers.
 # override mozmill's default logging case, which I hate.
 def logFailure(obj):
+    if isinstance(obj, basestring):
+        obj = simplejson.loads(obj)
     FAILURE_LIST.append(obj)
 def logEndTest(obj):
+    # If we've got a string here, we know we're later than 1.5, and we can just
+    # display a summary at the end as 1.5 will do TEST-UNEXPECTED-FAIL for us.
+    if isinstance(obj, str):
+        obj = simplejson.loads(obj)
+        obj['summary'] = True
     TEST_RESULTS.append(obj)
 #mozmill.LoggerListener.cases['mozmill.fail'] = logFailure
 mozmill.LoggerListener.cases['mozmill.endTest'] = logEndTest
 
 def prettifyFilename(path):
     lslash = path.rfind('/')
     if lslash != -1:
         return path[lslash+1:]
@@ -361,20 +372,23 @@ def prettyPrintException(e):
             else:
                 print '           ', prettifyFilename(path), line
 
 
 import pprint
 def prettyPrintResults():
     for result in TEST_RESULTS:
         #pprint.pprint(result)
+        testOrSummary = 'TEST'
+        if 'summary' in result:
+            testOrSummary = 'SUMMARY'
         if len(result['fails']) == 0:
-            print 'TEST-PASS | ', result['name']
+            print '%s-PASS | %s' % (testOrSummary, result['name'])
         else:
-            print 'TEST-UNEXPECTED-FAIL | %s | %s' % (prettifyFilename(result['filename']), result['name'])
+            print '%s-UNEXPECTED-FAIL | %s | %s' % (testOrSummary, prettifyFilename(result['filename']), result['name'])
         for failure in result['fails']:
             if 'exception' in failure:
                 prettyPrintException(failure['exception'])
 
 import atexit
 atexit.register(prettyPrintResults)
 
 def checkCrashesAtExit():