Bug 1290375 - Marionette has to report the test name and not runner.py for crashes. r=ato, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Fri, 05 Aug 2016 15:06:15 +0200
changeset 349729 67df3228b1e833fa6eabccf6eb388734deb24140
parent 349728 65f69c19b3c703615572e2d570e8eab34b18b8ea
child 349730 c16b845d20803e1d4e785b144ffd63e9545eb16b
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, test-only
bugs1290375
milestone50.0a2
Bug 1290375 - Marionette has to report the test name and not runner.py for crashes. r=ato, a=test-only MozReview-Commit-ID: 5WZv4bppp28
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/harness/marionette/tests/unit/test_marionette.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1134,18 +1134,18 @@ class Marionette(object):
         return self.session
 
     @property
     def test_name(self):
         return self._test_name
 
     @test_name.setter
     def test_name(self, test_name):
-        if self._send_message("setTestName", {"value": test_name}):
-            self._test_name = test_name
+        self._send_message("setTestName", {"value": test_name})
+        self._test_name = test_name
 
     def delete_session(self):
         """Close the current session and disconnect from the server."""
         self._send_message("deleteSession")
         self.session_id = None
         self.session = None
         self.window = None
         self.client.close()
--- a/testing/marionette/harness/marionette/tests/unit/test_marionette.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_marionette.py
@@ -1,27 +1,40 @@
 # 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/.
 
 import itertools
 
 from marionette_driver import errors
-from marionette.marionette_test import MarionetteTestCase as TC
+from marionette.marionette_test import MarionetteTestCase
 
 
-class TestProtocol1Errors(TC):
+class TestMarionetteProperties(MarionetteTestCase):
+
+    def test_correct_test_name(self):
+        """Test that the correct test name gets set."""
+        expected_test_name = '{module}.py {cls}.{func}'.format(
+            module=__name__,
+            cls=self.__class__.__name__,
+            func=self.test_correct_test_name.__name__,
+        )
+
+        self.assertEqual(self.marionette.test_name, expected_test_name)
+
+
+class TestProtocol1Errors(MarionetteTestCase):
     def setUp(self):
-        TC.setUp(self)
+        MarionetteTestCase.setUp(self)
         self.op = self.marionette.protocol
         self.marionette.protocol = 1
 
     def tearDown(self):
         self.marionette.protocol = self.op
-        TC.tearDown(self)
+        MarionetteTestCase.tearDown(self)
 
     def test_malformed_packet(self):
         for t in [{}, {"error": None}]:
             with self.assertRaisesRegexp(errors.MarionetteException, "Malformed packet"):
                 self.marionette._handle_error(t)
 
     def test_known_error_code(self):
         with self.assertRaises(errors.NoSuchElementException):
@@ -37,25 +50,25 @@ class TestProtocol1Errors(TC):
         with self.assertRaises(errors.MarionetteException):
             self.marionette._handle_error({"error": {"status": 123456}})
 
     def test_unknown_error_status(self):
         with self.assertRaises(errors.MarionetteException):
             self.marionette._handle_error({"error": {"status": "barbera"}})
 
 
-class TestProtocol2Errors(TC):
+class TestProtocol2Errors(MarionetteTestCase):
     def setUp(self):
-        TC.setUp(self)
+        MarionetteTestCase.setUp(self)
         self.op = self.marionette.protocol
         self.marionette.protocol = 2
 
     def tearDown(self):
         self.marionette.protocol = self.op
-        TC.tearDown(self)
+        MarionetteTestCase.tearDown(self)
 
     def test_malformed_packet(self):
         req = ["error", "message", "stacktrace"]
         ps = []
         for p in [p for i in range(0, len(req) + 1) for p in itertools.permutations(req, i)]:
             ps.append(dict((x, None) for x in p))
 
         for p in filter(lambda p: len(p) < 3, ps):