Bug 1328411 - Enforce relationship between e10s runner option and browser appinfo; r=automatedtester a=test-only
authorMaja Frydrychowicz <mjzffr@gmail.com>
Wed, 04 Jan 2017 12:06:36 -0500
changeset 353471 0e5631748857e7df0b8e9c849fb7348f3318dfe4
parent 353470 b074ffce576d52dcb830ea8316fd38a90af68424
child 353472 995ecbd221ea889edb6e597b8019491cb245be30
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1328411
milestone52.0a2
Bug 1328411 - Enforce relationship between e10s runner option and browser appinfo; r=automatedtester a=test-only MozReview-Commit-ID: KMOv9uNfjXH
testing/marionette/harness/marionette_harness/runner/base.py
testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_runner.py
--- a/testing/marionette/harness/marionette_harness/runner/base.py
+++ b/testing/marionette/harness/marionette_harness/runner/base.py
@@ -826,20 +826,23 @@ class BaseMarionetteTestRunner(object):
 
         device_info = None
         if self.marionette.instance and self.emulator:
             try:
                 device_info = self.marionette.instance.runner.device.dm.getInfo()
             except Exception:
                 self.logger.warning('Could not get device info', exc_info=True)
 
-        if self.appinfo.get('browserTabsRemoteAutostart', False):
-            self.logger.info("e10s is enabled")
-        else:
-            self.logger.info("e10s is disabled")
+        appinfo_e10s = self.appinfo.get('browserTabsRemoteAutostart', False)
+        self.logger.info("e10s is {}".format("enabled" if appinfo_e10s else "disabled"))
+        if self.e10s != appinfo_e10s:
+            message_e10s = ("BaseMarionetteTestRunner configuration (self.e10s) does "
+                            "not match browser appinfo")
+            self.cleanup()
+            raise AssertionError(message_e10s)
 
         self.logger.suite_start(self.tests,
                                 version_info=self.version_info,
                                 device_info=device_info)
 
         self._log_skipped_tests()
 
         interrupted = None
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_runner.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_runner.py
@@ -24,16 +24,18 @@ def mock_runner(runner, mock_marionette,
     MarionetteTestRunner instance with mocked-out
     self.marionette and other properties,
     to enable testing runner.run_tests().
     """
     runner.driverclass = mock_marionette
     for attr in ['run_test_set', '_capabilities']:
         setattr(runner, attr, Mock())
     runner._appName = 'fake_app'
+    # simulate that browser runs with e10s by default
+    runner._appinfo = {'browserTabsRemoteAutostart': True}
     monkeypatch.setattr('marionette_harness.runner.base.mozversion', Mock())
     return runner
 
 
 @pytest.fixture
 def build_kwargs_using(mach_parsed_kwargs):
     '''Helper function for test_build_kwargs_* functions'''
     def kwarg_builder(new_items, return_socket=False):
@@ -410,12 +412,31 @@ def test_catch_invalid_test_names(runner
         runner._add_tests(good_tests + bad_tests)
     msg = exc.value.message
     assert "Test file names must be of the form" in msg
     for bad_name in bad_tests:
         assert bad_name in msg
     for good_name in good_tests:
         assert good_name not in msg
 
+@pytest.mark.parametrize('e10s', (True, False))
+def test_e10s_option_sets_prefs(mach_parsed_kwargs, e10s):
+    mach_parsed_kwargs['e10s'] = e10s
+    runner = MarionetteTestRunner(**mach_parsed_kwargs)
+    e10s_prefs = {
+        'browser.tabs.remote.autostart': True,
+        'browser.tabs.remote.force-enable': True,
+        'extensions.e10sBlocksEnabling': False
+    }
+    for k,v in e10s_prefs.iteritems():
+        if k == 'extensions.e10sBlocksEnabling' and not e10s:
+            continue
+        assert runner.prefs.get(k, False) == (v and e10s)
+
+def test_e10s_option_clash_raises(mock_runner):
+    mock_runner.e10s = False
+    with pytest.raises(AssertionError) as e:
+        mock_runner.run_tests([u'test_fake_thing.py'])
+        assert "configuration (self.e10s) does not match browser appinfo" in e.value.message
 
 if __name__ == '__main__':
     import sys
     sys.exit(pytest.main(['--verbose', __file__]))