Patchwork [007,of,179,tests-refactor] run-tests: move killdaemons into Test.run()

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:37 p.m.
Message ID <ecc28a7efcb0ae480d29.1399055844@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4503/
State Accepted
Commit 9e5d8eaa4a2039a3013093cc1ed80c809e3b7679
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397938972 25200
#      Sat Apr 19 13:22:52 2014 -0700
# Branch stable
# Node ID ecc28a7efcb0ae480d29443990753eaee98ffd58
# Parent  5c920a6f7ff39411402ab7910db7c1520ca550fb
run-tests: move killdaemons into Test.run()

killdaemons() was the only part of runone() looking at env variables. We
move killdaemons() into Test.run() to enable us to fully move env into
Test.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -553,17 +553,20 @@  class Test(object):
         self.testtmp = os.path.join(threadtmp, os.path.basename(path))
         os.mkdir(self.testtmp)
 
         self._setreplacements(count)
 
     def run(self, env):
         createhgrc(env['HGRCPATH'], self._options)
 
-        return self._run(self._replacements, env)
+        try:
+            return self._run(self._replacements, env)
+        finally:
+            killdaemons(env['DAEMON_PIDS'])
 
     def _run(self, replacements, env):
         raise NotImplemented('Subclasses must implement Test.run()')
 
     def _setreplacements(self, count):
         port = self._options.port + count * 3
         r = [
             (r':%s\b' % port, ':$HGPORT'),
@@ -1029,18 +1032,16 @@  def runone(options, test, count):
     except KeyboardInterrupt:
         endtime = time.time()
         log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime))
         raise
     endtime = time.time()
     times.append((test, endtime - starttime))
     vlog("# Ret was:", ret)
 
-    killdaemons(env['DAEMON_PIDS'])
-
     skipped = (ret == SKIPPED_STATUS)
 
     # If we're not in --debug mode and reference output file exists,
     # check test output against it.
     if options.debug:
         refout = None                   # to match "out is None"
     elif os.path.exists(ref):
         f = open(ref, "r")