# HG changeset patch # User Gregory Szorc # Date 1397958640 25200 # Node ID 6b3d66e4d3bed7d3bf5c7b96eec9d218f193729a # Parent 58a599784a0cdfa2f0f2e1f0df673adc9e5236e5 run-tests: capture reference output in Test.__init__ Reference output should be constant and doesn't need to be computed at test execution time. We calculate it earlier. This patch is the first in a mini series that will change how the TestResult object works. diff -r 58a599784a0c -r 6b3d66e4d3be tests/run-tests.py --- a/tests/run-tests.py Sat Apr 19 16:14:30 2014 -0700 +++ b/tests/run-tests.py Sat Apr 19 18:50:40 2014 -0700 @@ -551,11 +551,22 @@ runs cannot be run concurrently. """ - def __init__(self, path, options, count): + def __init__(self, path, options, count, refpath): self._path = path self._options = options self._count = count + # If we're not in --debug mode and reference output file exists, + # check test output against it. + if options.debug: + self._refout = None # to match "out is None" + elif os.path.exists(refpath): + f = open(refpath, 'r') + self._refout = f.read().splitlines(True) + f.close() + else: + self._refout = [] + self._threadtmp = os.path.join(HGTMP, 'child%d' % count) os.mkdir(self._threadtmp) @@ -563,7 +574,7 @@ if self._threadtmp and not self._options.keep_tmpdir: shutil.rmtree(self._threadtmp, True) - def run(self, result, refpath): + def run(self, result): testtmp = os.path.join(self._threadtmp, os.path.basename(self._path)) os.mkdir(testtmp) replacements, port = self._getreplacements(testtmp) @@ -589,16 +600,7 @@ killdaemons(env['DAEMON_PIDS']) - # If we're not in --debug mode and reference output file exists, - # check test output against it. - if self._options.debug: - result.refout = None # to match "out is None" - elif os.path.exists(refpath): - f = open(refpath, 'r') - result.refout = f.read().splitlines(True) - f.close() - else: - result.refout = [] + result.refout = self._refout if not self._options.keep_tmpdir: shutil.rmtree(testtmp) @@ -1084,9 +1086,9 @@ if os.path.exists(err): os.remove(err) # Remove any previous output files - t = runner(testpath, options, count) + t = runner(testpath, options, count, ref) res = TestResult() - t.run(res, ref) + t.run(res) t.cleanup() if res.interrupted: