Bug 1541215 - [raptor] Check for failures in spawned thread for test_start_browser. r=rwood
authorHenrik Skupin <mail@hskupin.info>
Thu, 04 Apr 2019 06:12:23 +0000
changeset 467909 bf54318fe559218e7ffa139a9ad0cf3c3869bf43
parent 467908 4b426a0865626537c0d59f78d651c934adc750b9
child 467910 a77666feb3580c20b3b0f23bed0254cd90be05e4
push id35813
push useraiakab@mozilla.com
push dateThu, 04 Apr 2019 16:07:30 +0000
treeherdermozilla-central@aa623df2ae8f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1541215
milestone68.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 1541215 - [raptor] Check for failures in spawned thread for test_start_browser. r=rwood Differential Revision: https://phabricator.services.mozilla.com/D25855
testing/raptor/test/test_raptor.py
--- a/testing/raptor/test/test_raptor.py
+++ b/testing/raptor/test/test_raptor.py
@@ -19,16 +19,31 @@ if os.environ.get('SCRIPTSPATH', None) i
 else:
     # locally it's in source tree
     mozharness_dir = os.path.join(here, '../../mozharness')
 sys.path.insert(0, mozharness_dir)
 
 from raptor.raptor import RaptorDesktopFirefox, RaptorDesktopChrome, RaptorAndroid
 
 
+class TestBrowserThread(threading.Thread):
+        def __init__(self, raptor_instance, test, timeout=None):
+            super(TestBrowserThread, self).__init__()
+            self.raptor_instance = raptor_instance
+            self.test = test
+            self.timeout = timeout
+            self.exc = None
+
+        def run(self):
+            try:
+                self.raptor_instance.run_test(self.test, self.timeout)
+            except BaseException:
+                self.exc = sys.exc_info()
+
+
 @pytest.mark.parametrize("raptor_class, app_name", [
                          [RaptorDesktopFirefox, "firefox"],
                          [RaptorDesktopChrome, "chrome"],
                          [RaptorAndroid, "fennec"],
                          [RaptorAndroid, "geckoview"],
                          ])
 def test_create_profile(options, raptor_class, app_name, get_prefs):
     options['app'] = app_name
@@ -86,30 +101,35 @@ def test_start_browser(get_binary, app):
     raptor = RaptorDesktopFirefox(app, binary)
     raptor.create_browser_profile()
     raptor.create_browser_handler()
     raptor.start_control_server()
 
     test = {}
     test['name'] = 'raptor-{}-tp6'.format(app)
 
-    thread = threading.Thread(target=raptor.run_test, args=(test,))
+    thread = TestBrowserThread(raptor, test)
     thread.start()
 
     timeout = time.time() + 5  # seconds
     while time.time() < timeout:
         try:
             is_running = raptor.runner.is_running()
             assert is_running
             break
         except RunnerNotStartedError:
             time.sleep(0.1)
     else:
         assert False  # browser didn't start
 
     raptor.clean_up()
     thread.join(5)
+
+    if thread.exc is not None:
+        exc, value, tb = thread.exc
+        raise exc, value, tb
+
     assert not raptor.runner.is_running()
     assert raptor.runner.returncode is not None
 
 
 if __name__ == '__main__':
     mozunit.main()