[PATCH 026 of 179 tests-refactor] run-tests: move err path handling to Test
Gregory Szorc
gregory.szorc at gmail.com
Fri May 2 18:37:43 UTC 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1397964758 25200
# Sat Apr 19 20:32:38 2014 -0700
# Branch stable
# Node ID f2dcc9e961414939d38985099a6d192e176c718b
# Parent 6688e53bdf9587c8f6d347e2d3f25de231c7f425
run-tests: move err path handling to Test
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -544,22 +544,24 @@ def outputcoverage(options):
class Test(object):
"""Encapsulates a single, runnable test.
Test instances can be run multiple times via run(). However, multiple
runs cannot be run concurrently.
"""
- def __init__(self, test, path, options, count, refpath):
+ def __init__(self, test, path, options, count, refpath, errpath):
self._test = test
self._path = path
self._options = options
self._count = count
self._daemonpids = []
+ self._refpath = refpath
+ self._errpath = errpath
# 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)
@@ -573,16 +575,20 @@ class Test(object):
def __del__(self):
for entry in self._daemonpids:
killdaemons(entry)
if self._threadtmp and not self._options.keep_tmpdir:
shutil.rmtree(self._threadtmp, True)
def run(self, result):
+ # Remove any previous output files.
+ if os.path.exists(self._errpath):
+ os.remove(self._errpath)
+
testtmp = os.path.join(self._threadtmp, os.path.basename(self._path))
os.mkdir(testtmp)
replacements, port = self._getreplacements(testtmp)
env = self._getenv(testtmp, port)
self._daemonpids.append(env['DAEMON_PIDS'])
createhgrc(env['HGRCPATH'], self._options)
starttime = time.time()
@@ -1083,20 +1089,17 @@ def runone(options, test, count):
runner = cls
ref = os.path.join(TESTDIR, test + out)
break
else:
return skip("unknown test type")
vlog("# Test", test)
- if os.path.exists(err):
- os.remove(err) # Remove any previous output files
-
- t = runner(test, testpath, options, count, ref)
+ t = runner(test, testpath, options, count, ref, err)
res = TestResult()
t.run(res)
del t # For cleanup side-effects.
if res.exception:
return fail('Exception during execution: %s' % res.exception, 255)
ret = res.ret
More information about the Mercurial-devel
mailing list