# HG changeset patch # User Gregory Szorc # Date 1397941786 25200 # Node ID 935ade2072534932ad37e70539e23d55ea62b937 # Parent cd4fd7b3c3c4c3b98b4fa39e7d9be8a6d4c371ba run-tests: capture reference output in TestResult class diff -r cd4fd7b3c3c4 -r 935ade207253 tests/run-tests.py --- 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