run-tests: move env into Test
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 19 Apr 2014 13:26:12 -0700
changeset 21303 21a706020dd6
parent 21302 9e5d8eaa4a20
child 21304 e626a67da4ba
run-tests: move env into Test Environment variables are an implementation detail of how tests are executed. This patch moves environment variable logic into Test and completely hides it from the outside. With this patch, a Test can be executed with two lines: init + run(). Tests are still single-use and take a more arguments to the constructor than likely necessary. These will get addressed in subsequent patches.
tests/run-tests.py
--- a/tests/run-tests.py	Sat Apr 19 13:22:52 2014 -0700
+++ b/tests/run-tests.py	Sat Apr 19 13:26:12 2014 -0700
@@ -557,7 +557,8 @@
 
         self._setreplacements(count)
 
-    def run(self, env):
+    def run(self):
+        env = self._getenv()
         createhgrc(env['HGRCPATH'], self._options)
 
         try:
@@ -587,7 +588,7 @@
         self._replacements = r
         self._port = port
 
-    def getenv(self):
+    def _getenv(self):
         env = os.environ.copy()
         env['TESTTMP'] = self.testtmp
         env['HOME'] = self.testtmp
@@ -1026,11 +1027,10 @@
     os.mkdir(threadtmp)
 
     t = runner(testpath, options, threadtmp, count)
-    env = t.getenv()
 
     starttime = time.time()
     try:
-        ret, out = t.run(env)
+        ret, out = t.run()
     except KeyboardInterrupt:
         endtime = time.time()
         log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime))