[PATCH 040 of 179 tests-refactor] run-tests: move output writing to Test.run()
Gregory Szorc
gregory.szorc at gmail.com
Fri May 2 13:37:57 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1397967459 25200
# Sat Apr 19 21:17:39 2014 -0700
# Branch stable
# Node ID c89ba785dd16e616d81d1147d1b813a1342fbccb
# Parent 502c9d9909022e802e28e62760d2c219b6dc5051
run-tests: move output writing to Test.run()
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -620,18 +620,16 @@ class Test(object):
starttime = time.time()
def updateduration():
result.duration = time.time() - starttime
try:
ret, out = self._run(testtmp, replacements, env)
updateduration()
- result.ret = ret
- result.out = out
except KeyboardInterrupt:
updateduration()
log('INTERRUPTED: %s (after %d seconds)' % (self._test,
result.duration))
raise
except Exception, e:
updateduration()
return self.fail('Exception during execution: %s' % e, 255)
@@ -691,16 +689,24 @@ class Test(object):
if (ret != 0 or out != self._refout) and not result.skipped \
and not options.debug:
f = open(self._errpath, 'wb')
for line in out:
f.write(line)
f.close()
+ vlog("# Ret was:", ret)
+
+ if not options.verbose:
+ iolock.acquire()
+ sys.stdout.write(res[0])
+ sys.stdout.flush()
+ iolock.release()
+
return res
def _run(self, testtmp, replacements, env):
raise NotImplemented('Subclasses must implement Test.run()')
def _getreplacements(self, testtmp):
port = self._options.port + self._count * 3
r = [
@@ -786,18 +792,16 @@ class Test(object):
def ignore(self, msg):
return 'i', self._test, msg
class TestResult(object):
"""Holds the result of a test execution."""
def __init__(self):
- self.ret = None
- self.out = None
self.duration = None
self.skipped = False
class PythonTest(Test):
"""A Python-based test."""
def _run(self, testtmp, replacements, env):
py3kswitch = self._options.py3k_warnings and ' -3' or ''
cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path)
@@ -1150,27 +1154,17 @@ def runone(options, test, count):
return skip("unknown test type")
vlog("# Test", test)
t = runner(test, testpath, options, count, ref, err)
res = TestResult()
result = t.run(res)
- ret = res.ret
- out = res.out
-
times.append((test, res.duration))
- vlog("# Ret was:", ret)
-
- if not options.verbose:
- iolock.acquire()
- sys.stdout.write(result[0])
- sys.stdout.flush()
- iolock.release()
del t # For cleanup side-effects.
return result
_hgpath = None
def _gethgpath():
More information about the Mercurial-devel
mailing list