# HG changeset patch # User Gregory Szorc # Date 1397939172 25200 # Node ID 21a706020dd64be83d91760124d4248c3a13e2c1 # Parent 9e5d8eaa4a2039a3013093cc1ed80c809e3b7679 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. diff -r 9e5d8eaa4a20 -r 21a706020dd6 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))