run-tests: store last result in Test._result
Subsequent patches move post-test actions into tearDown(). This requires
tearDown() to have access to the last result.
--- a/tests/run-tests.py Sun Apr 20 15:00:13 2014 -0700
+++ b/tests/run-tests.py Sun Apr 20 15:08:05 2014 -0700
@@ -360,6 +360,7 @@
self._ret = None
self._out = None
self._duration = None
+ self._result = None
# If we're not in --debug mode and reference output file exists,
# check test output against it.
@@ -388,6 +389,7 @@
self._ret = None
self._out = None
self._duration = None
+ self._result = None
def run(self):
"""Run this test instance.
@@ -472,13 +474,13 @@
missing = ['irrelevant']
if failed:
- res = self.fail('hg have failed checking for %s' % failed[-1],
- ret)
+ self._result = self.fail('hg have failed checking for %s' %
+ failed[-1], ret)
else:
skipped = True
- res = self.skip(missing[-1])
+ self._result = self.skip(missing[-1])
elif ret == 'timeout':
- res = self.fail('timed out', ret)
+ self._result = self.fail('timed out', ret)
elif out != self._refout:
info = {}
if not options.nodiff:
@@ -504,11 +506,12 @@
for line in out:
f.write(line)
f.close()
- res = self.fail(msg, ret)
+
+ self._result = self.fail(msg, ret)
elif ret:
- res = self.fail(describe(ret), ret)
+ self._result = self.fail(describe(ret), ret)
else:
- res = self.success()
+ self._result = self.success()
vlog("# Ret was:", ret)
@@ -517,14 +520,14 @@
# by TestResult.
if not options.verbose and not self._unittest:
iolock.acquire()
- sys.stdout.write(res[0])
+ sys.stdout.write(self._result[0])
sys.stdout.flush()
iolock.release()
if not self._unittest:
self.tearDown()
- return res
+ return self._result
def tearDown(self):
"""Tasks to perform after run()."""