Bug 914571 - Avoid overwriting the marionette loglines. r=jgriffin
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Wed, 11 Sep 2013 09:38:55 -0400
changeset 146630 6372efd4b8356b4e113adbef6adf01f69eea598f
parent 146629 cfb005bc3debb8dd99e4eb13eda14ce22c9525d4
child 146631 1f3062a59abb61102177a5f0f7d5888b979e9c1f
push id25267
push userryanvm@gmail.com
push dateThu, 12 Sep 2013 00:58:25 +0000
treeherdermozilla-central@2f11fad2f307 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs914571
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 914571 - Avoid overwriting the marionette loglines. r=jgriffin
testing/marionette/client/marionette/marionette_test.py
testing/marionette/client/marionette/runtests.py
--- a/testing/marionette/client/marionette/marionette_test.py
+++ b/testing/marionette/client/marionette/marionette_test.py
@@ -79,17 +79,17 @@ def skip_if_b2g(target):
 
 class CommonTestCase(unittest.TestCase):
 
     match_re = None
     failureException = AssertionError
 
     def __init__(self, methodName):
         unittest.TestCase.__init__(self, methodName)
-        self.loglines = None
+        self.loglines = []
         self.duration = 0
 
     def _addSkip(self, result, reason):
         addSkip = getattr(result, 'addSkip', None)
         if addSkip is not None:
             addSkip(self, reason)
         else:
             warnings.warn("TestResult has no addSkip method, skips not reported",
@@ -248,17 +248,17 @@ permissions.forEach(function (perm) {
         self._deleteSession()
 
     def _deleteSession(self):
         if hasattr(self, 'start_time'):
             self.duration = time.time() - self.start_time
         if hasattr(self.marionette, 'session'):
             if self.marionette.session is not None:
                 try:
-                    self.loglines = self.marionette.get_logs()
+                    self.loglines.extend(self.marionette.get_logs())
                 except Exception, inst:
                     self.loglines = [['Error getting log: %s' % inst]]
                 try:
                     self.marionette.delete_session()
                 except (socket.error, MarionetteException):
                     # Gecko has crashed?
                     self.marionette.session = None
                     try:
@@ -295,22 +295,22 @@ class MarionetteTestCase(CommonTestCase)
                                   methodName=testname,
                                   filepath=filepath,
                                   testvars=testvars,
                                   **kwargs))
 
     def setUp(self):
         CommonTestCase.setUp(self)
         self.marionette.test_name = self.test_name
-        self.marionette.execute_script("log('TEST-START: %s:%s')" % 
+        self.marionette.execute_script("log('TEST-START: %s:%s')" %
                                        (self.filepath.replace('\\', '\\\\'), self.methodName))
 
     def tearDown(self):
         self.marionette.set_context("content")
-        self.marionette.execute_script("log('TEST-END: %s:%s')" % 
+        self.marionette.execute_script("log('TEST-END: %s:%s')" %
                                        (self.filepath.replace('\\', '\\\\'), self.methodName))
         self.marionette.test_name = None
         CommonTestCase.tearDown(self)
 
     def get_new_emulator(self):
         self.extra_emulator_index += 1
         if len(self.marionette.extra_emulators) == self.extra_emulator_index:
             qemu  = Marionette(emulator=self.marionette.emulator.arch,
--- a/testing/marionette/client/marionette/runtests.py
+++ b/testing/marionette/client/marionette/runtests.py
@@ -87,17 +87,17 @@ class MarionetteTestResult(unittest._Tex
                 skip_log = True
                 for line in testcase.loglines:
                     str_line = ' '.join(line)
                     if not 'TEST-END' in str_line and not 'TEST-START' in str_line:
                         skip_log = False
                         break
                 if skip_log:
                     return
-                self.stream.writeln('START LOG:')
+                self.stream.writeln('\nSTART LOG:')
                 for line in testcase.loglines:
                     self.stream.writeln(' '.join(line).encode('ascii', 'replace'))
                 self.stream.writeln('END LOG:')
 
     def printErrorList(self, flavour, errors):
         for error in errors:
             test, err = error[:2]
             self.stream.writeln(self.separator1)
@@ -154,18 +154,18 @@ class MarionetteTextTestRunner(unittest.
         try:
             test(result)
         finally:
             stopTestRun = getattr(result, 'stopTestRun', None)
             if stopTestRun is not None:
                 stopTestRun()
         stopTime = time.time()
         timeTaken = stopTime - startTime
+        result.printLogs(test)
         result.printErrors()
-        result.printLogs(test)
         if hasattr(result, 'separator2'):
             self.stream.writeln(result.separator2)
         run = result.testsRun
         self.stream.writeln("Ran %d test%s in %.3fs" %
                             (run, run != 1 and "s" or "", timeTaken))
         self.stream.writeln()
 
         expectedFails = unexpectedSuccesses = skipped = 0