Patchwork [005,of,179,tests-refactor] run-tests: move createhgrc() call into Test.run()

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

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397938309 25200
#      Sat Apr 19 13:11:49 2014 -0700
# Branch stable
# Node ID 27f7274d1694f92571e68c63696cead7658271eb
# Parent  71520e4115ab64e38cc872ec04044f37c747ffcf
run-tests: move createhgrc() call into Test.run()

createhgrc() is an implementation detail of how tests are run. It makes
sense to move it into Test.run().

Note that this will cause the test execution time to include the
creation of hgrc. The author does not believe this is a significant
change worth worrying about.
Pierre-Yves David - May 7, 2014, 8:39 p.m.
On 05/02/2014 11:37 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1397938309 25200
> #      Sat Apr 19 13:11:49 2014 -0700
> # Branch stable
> # Node ID 27f7274d1694f92571e68c63696cead7658271eb
> # Parent  71520e4115ab64e38cc872ec04044f37c747ffcf
> run-tests: move createhgrc() call into Test.run()
>
> createhgrc() is an implementation detail of how tests are run. It makes
> sense to move it into Test.run().
>
> Note that this will cause the test execution time to include the
> creation of hgrc. The author does not believe this is a significant
> change worth worrying about.

including hgrc time does not seems a real issue. Do you, later in your 
series make a distinction between test setup and actual test run?

is methods needs a docstring.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -549,16 +549,18 @@  class Test(object):
         self._path = path
         self._options = options
         self._threadtmp = threadtmp
 
         self.testtmp = os.path.join(threadtmp, os.path.basename(path))
         os.mkdir(self.testtmp)
 
     def run(self, replacements, env):
+        createhgrc(env['HGRCPATH'], self._options)
+
         return self._run(replacements, env)
 
     def _run(self, replacements, env):
         raise NotImplemented('Subclasses must implement Test.run()')
 
     def getreplacements(self, count):
         port = self._options.port + count * 3
         r = [
@@ -1013,17 +1015,16 @@  def runone(options, test, count):
 
     # Make a tmp subdirectory to work in
     threadtmp = os.path.join(HGTMP, "child%d" % count)
     os.mkdir(threadtmp)
 
     t = runner(testpath, options, threadtmp)
     replacements, port = t.getreplacements(count)
     env = t.getenv(port)
-    createhgrc(env['HGRCPATH'], options)
 
     starttime = time.time()
     try:
         ret, out = t.run(replacements, env)
     except KeyboardInterrupt:
         endtime = time.time()
         log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime))
         raise