Bug 1287591 - The application should not be started and left open if filtering of a single manifest file does not find any test draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 27 Jul 2016 00:11:53 +0200
changeset 393342 c028be63fdbe603c8ba124f71599e65cf79c7bd4
parent 393304 fef429fba4c64c5b9c0c823a6ab713edbbcd4220
child 526568 680f78827fa648dd976e2a39456128f0733e8472
push id24294
push userbmo:hskupin@gmail.com
push dateWed, 27 Jul 2016 18:50:23 +0000
bugs1287591
milestone50.0a1
Bug 1287591 - The application should not be started and left open if filtering of a single manifest file does not find any test MozReview-Commit-ID: BjkwyQilCEE
testing/marionette/harness/marionette/runner/base.py
--- a/testing/marionette/harness/marionette/runner/base.py
+++ b/testing/marionette/harness/marionette/runner/base.py
@@ -664,21 +664,17 @@ class BaseMarionetteTestRunner(object):
     def bin(self, path):
         """
         Set binary and reset parts of runner accordingly
 
         Intended use: to change binary between calls to run_tests
         """
         self._bin = path
         self.tests = []
-        if hasattr(self, 'marionette') and self.marionette:
-            self.marionette.cleanup()
-            if self.marionette.instance:
-                self.marionette.instance = None
-        self.marionette = None
+        self.cleanup()
 
     def reset_test_stats(self):
         self.passed = 0
         self.failed = 0
         self.crashed = 0
         self.unexpected_successes = 0
         self.todo = 0
         self.skipped = 0
@@ -891,38 +887,41 @@ setReq.onerror = function() {
                     self.logger.info('\nREPEAT %d\n-------' % round_num)
                 self.run_test_sets()
                 counter -= 1
         except KeyboardInterrupt:
             # in case of KeyboardInterrupt during the test execution
             # we want to display current test results.
             # so we keep the exception to raise it later.
             interrupted = sys.exc_info()
+        except:
+            # For any other exception we return immediately and have to
+            # cleanup running processes
+            self.cleanup()
+            raise
+
         try:
             self._print_summary(tests)
             self.record_crash()
             self.elapsedtime = time.time() - start_time
 
-            if self.marionette.instance:
-                self.marionette.instance.close()
-                self.marionette.instance = None
-            self.marionette.cleanup()
-
             for run_tests in self.mixin_run_tests:
                 run_tests(tests)
             if self.shuffle:
                 self.logger.info("Using seed where seed is:%d" % self.shuffle_seed)
 
             self.logger.info('mode: {}'.format('e10s' if self.e10s else 'non-e10s'))
             self.logger.suite_end()
         except:
             # raise only the exception if we were not interrupted
             if not interrupted:
                 raise
         finally:
+            self.cleanup()
+
             # reraise previous interruption now
             if interrupted:
                 raise interrupted[0], interrupted[1], interrupted[2]
 
     def _print_summary(self, tests):
         self.logger.info('\nSUMMARY\n-------')
         self.logger.info('passed: %d' % self.passed)
         if self.unexpected_successes == 0:
@@ -1085,15 +1084,21 @@ setReq.onerror = function() {
                              'total of %d)' % (self.this_chunk, self.total_chunks,
                                                len(chunks[self.this_chunk - 1]),
                                                len(self.tests)))
             self.tests = chunks[self.this_chunk - 1]
 
         self.run_test_set(self.tests)
 
     def cleanup(self):
-        if self.httpd:
+        if hasattr(self, 'httpd') and self.httpd:
             self.httpd.stop()
+            self.httpd = None
 
-        if self.marionette:
+        if hasattr(self, 'marionette') and self.marionette:
+            if self.marionette.instance:
+                self.marionette.instance.close()
+                self.marionette.instance = None
+
             self.marionette.cleanup()
+            self.marionette = None
 
     __del__ = cleanup