Mercurial > hg
changeset 21308:935ade207253
run-tests: capture reference output in TestResult class
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 14:09:46 -0700 |
parents | cd4fd7b3c3c4 |
children | 0b123e6a318c |
files | tests/run-tests.py |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Apr 19 14:01:18 2014 -0700 +++ b/tests/run-tests.py Sat Apr 19 14:09:46 2014 -0700 @@ -559,7 +559,7 @@ self._setreplacements(count) - def run(self, result): + def run(self, result, refpath): env = self._getenv() createhgrc(env['HGRCPATH'], self._options) @@ -582,6 +582,17 @@ 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 = [] + def _run(self, replacements, env): raise NotImplemented('Subclasses must implement Test.run()') @@ -648,6 +659,7 @@ self.duration = None self.interrupted = False self.exception = None + self.refout = None @property def skipped(self): @@ -1055,7 +1067,7 @@ t = runner(testpath, options, count) res = TestResult() - t.run(res) + t.run(res, ref) if res.interrupted: log('INTERRUPTED: %s (after %d seconds)' % (test, res.duration)) @@ -1071,17 +1083,7 @@ vlog("# Ret was:", ret) skipped = res.skipped - - # If we're not in --debug mode and reference output file exists, - # check test output against it. - if options.debug: - refout = None # to match "out is None" - elif os.path.exists(ref): - f = open(ref, "r") - refout = f.read().splitlines(True) - f.close() - else: - refout = [] + refout = res.refout if (ret != 0 or out != refout) and not skipped and not options.debug: # Save errors to a file for diagnosis