Bug 1370863 - Stop using Marionette.log API in harness; r=automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Fri, 09 Jun 2017 14:27:27 +0100
changeset 598398 02b1ab7cd3ddecd7fc490433d6c37beb145e7cfd
parent 598307 92eb911c35da48907d326604c4c92cf55e551895
child 598399 3ae2bb18bda02a9dcdea2caf3eb04a66f5ea72f3
push id65195
push userbmo:ato@sny.no
push dateWed, 21 Jun 2017 18:07:04 +0000
reviewersautomatedtester
bugs1370863
milestone56.0a1
Bug 1370863 - Stop using Marionette.log API in harness; r=automatedtester MozReview-Commit-ID: 33ZPdJ486rJ
testing/marionette/harness/marionette_harness/marionette_test/testcases.py
testing/marionette/harness/marionette_harness/tests/unit/test_log.py
testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini
--- a/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
+++ b/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
@@ -67,17 +67,16 @@ class CommonTestCase(unittest.TestCase):
 
     def __init__(self, methodName, marionette_weakref, fixtures, **kwargs):
         super(CommonTestCase, self).__init__(methodName)
         self.methodName = methodName
 
         self._marionette_weakref = marionette_weakref
         self.fixtures = fixtures
 
-        self.loglines = []
         self.duration = 0
         self.start_time = 0
         self.expected = kwargs.pop('expected', 'pass')
         self.logger = get_default_logger()
 
     def _enter_pm(self):
         if self.pydebugger:
             self.pydebugger.post_mortem(sys.exc_info()[2])
@@ -246,32 +245,27 @@ class CommonTestCase(unittest.TestCase):
         self.marionette = self._marionette_weakref()
         if self.marionette.session is None:
             self.marionette.start_session()
         self.marionette.timeout.reset()
 
         super(CommonTestCase, self).setUp()
 
     def cleanTest(self):
-        self._deleteSession()
+        self._delete_session()
 
-    def _deleteSession(self):
-        if hasattr(self, 'start_time'):
+    def _delete_session(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.extend(self.marionette.get_logs())
-                except Exception, inst:
-                    self.loglines = [['Error getting log: {}'.format(inst)]]
-                try:
-                    self.marionette.delete_session()
-                except IOError:
-                    # Gecko has crashed?
-                    pass
+        if self.marionette.session is not None:
+            try:
+                self.marionette.delete_session()
+            except IOError:
+                # Gecko has crashed?
+                pass
         self.marionette = None
 
 
 class MarionetteTestCase(CommonTestCase):
 
     match_re = re.compile(r"test_(.*)\.py$")
 
     def __init__(self, marionette_weakref, fixtures, methodName='runTest',
@@ -312,29 +306,29 @@ class MarionetteTestCase(CommonTestCase)
                                       methodName=testname,
                                       filepath=filepath,
                                       testvars=testvars,
                                       **kwargs))
 
     def setUp(self):
         super(MarionetteTestCase, self).setUp()
         self.marionette.test_name = self.test_name
-        self.marionette.execute_script("log('TEST-START: {0}')"
+        self.marionette.execute_script("dump('TEST-START: {0}')"
                                        .format(self.test_name),
                                        sandbox="simpletest")
 
     def tearDown(self):
         # In the case no session is active (eg. the application was quit), start
         # a new session for clean-up steps.
         if not self.marionette.session:
             self.marionette.start_session()
 
         if not self.marionette.crashed:
             try:
-                self.marionette.execute_script("log('TEST-END: {0}')"
+                self.marionette.execute_script("dump('TEST-END: {0}')"
                                                .format(self.test_name),
                                                sandbox="simpletest")
                 self.marionette.test_name = None
             except (MarionetteException, IOError):
                 # We have tried to log the test end when there is no listener
                 # object that we can access
                 pass
 
deleted file mode 100644
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_log.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from marionette_harness import MarionetteTestCase
-
-
-class TestLog(MarionetteTestCase):
-    def setUp(self):
-        MarionetteTestCase.setUp(self)
-        # clears log cache
-        self.marionette.get_logs()
-
-    def test_log(self):
-        self.marionette.log("foo")
-        logs = self.marionette.get_logs()
-        self.assertEqual("INFO", logs[0][0])
-        self.assertEqual("foo", logs[0][1])
-
-    def test_log_level(self):
-        self.marionette.log("foo", "ERROR")
-        logs = self.marionette.get_logs()
-        self.assertEqual("ERROR", logs[0][0])
-        self.assertEqual("foo", logs[0][1])
-
-    def test_clear(self):
-        self.marionette.log("foo")
-        self.assertEqual(1, len(self.marionette.get_logs()))
-        self.assertEqual(0, len(self.marionette.get_logs()))
-
-    def test_multiple_entries(self):
-        self.marionette.log("foo")
-        self.marionette.log("bar")
-        self.assertEqual(2, len(self.marionette.get_logs()))
-
-    def test_log_from_sync_script(self):
-        self.marionette.execute_script("log('foo')")
-        logs = self.marionette.get_logs()
-        self.assertEqual("INFO", logs[0][0])
-        self.assertEqual("foo", logs[0][1])
-
-    def test_log_from_sync_script_level(self):
-        self.marionette.execute_script("log('foo', 'ERROR')")
-        logs = self.marionette.get_logs()
-        self.assertEqual("ERROR", logs[0][0])
-        self.assertEqual("foo", logs[0][1])
-
-    def test_log_from_async_script(self):
-        self.marionette.execute_async_script("log('foo'); arguments[0]();")
-        logs = self.marionette.get_logs()
-        self.assertEqual("INFO", logs[0][0])
-        self.assertEqual("foo", logs[0][1])
-
-    def test_log_from_async_script_variable_arguments(self):
-        self.marionette.execute_async_script("log('foo', 'ERROR'); arguments[0]();")
-        logs = self.marionette.get_logs()
-        self.assertEqual("ERROR", logs[0][0])
-        self.assertEqual("foo", logs[0][1])
-
-
-class TestLogChrome(TestLog):
-    def setUp(self):
-        TestLog.setUp(self)
-        self.marionette.set_context("chrome")
--- a/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini
+++ b/testing/marionette/harness/marionette_harness/tests/unit/unit-tests.ini
@@ -24,18 +24,16 @@ skip-if = appname == 'fennec'
 skip-if = appname == 'fennec'
 [test_text.py]
 [test_text_chrome.py]
 skip-if = true # "Bug 896046"
 
 [test_clearing.py]
 [test_typing.py]
 
-[test_log.py]
-
 [test_execute_async_script.py]
 [test_execute_script.py]
 [test_element_retrieval.py]
 [test_findelement_chrome.py]
 skip-if = appname == 'fennec'
 
 [test_get_current_url_chrome.py]
 [test_navigation.py]