Mercurial > hg
changeset 21523:9fb6f328576a
run-tests: move interactive test acceptance into TestResult
We shouldn't be performing interactive prompting during test execution.
The first step of this is to move the functionality into TestResult.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 22 Apr 2014 13:32:05 -0700 |
parents | eeaec308ad5f |
children | 47b97d9af27e |
files | tests/run-tests.py |
diffstat | 1 files changed, 22 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Tue Apr 22 13:25:17 2014 -0700 +++ b/tests/run-tests.py Tue Apr 22 13:32:05 2014 -0700 @@ -340,7 +340,7 @@ def __init__(self, path, tmpdir, keeptmpdir=False, debug=False, - interactive=False, timeout=defaults['timeout'], + timeout=defaults['timeout'], startport=defaults['port'], extraconfigopts=None, py3kwarnings=False, shell=None): """Create a test from parameters. @@ -355,8 +355,6 @@ debug mode will make the test execute verbosely, with unfiltered output. - interactive controls whether the test will run interactively. - timeout controls the maximum run time of the test. It is ignored when debug is True. @@ -382,7 +380,6 @@ self._threadtmp = tmpdir self._keeptmpdir = keeptmpdir self._debug = debug - self._interactive = interactive self._timeout = timeout self._startport = startport self._extraconfigopts = extraconfigopts or [] @@ -520,17 +517,17 @@ missing = ['irrelevant'] if failed: - self.fail('hg have failed checking for %s' % failed[-1], ret) + self.fail('hg have failed checking for %s' % failed[-1]) else: self._skipped = True raise SkipTest(missing[-1]) elif ret == 'timeout': - self.fail('timed out', ret) + self.fail('timed out') elif ret is False: raise WarnTest('no result code from test') elif out != self._refout: # The result object handles diff calculation for us. - self._result.addOutputMismatch(self, out, self._refout) + self._result.addOutputMismatch(self, ret, out, self._refout) if ret: msg = 'output changed and ' + describe(ret) @@ -544,9 +541,9 @@ f.write(line) f.close() - self.fail(msg, ret) + self.fail(msg) elif ret: - self.fail(describe(ret), ret) + self.fail(describe(ret)) def tearDown(self): """Tasks to perform after run().""" @@ -645,21 +642,7 @@ hgrc.write('[%s]\n%s\n' % (section, key)) hgrc.close() - def fail(self, msg, ret): - if (not ret and self._interactive and - os.path.exists(self.errpath)): - iolock.acquire() - print 'Accept this change? [n] ', - answer = sys.stdin.readline().strip() - iolock.release() - if answer.lower() in ('y', 'yes'): - if self.name.endswith('.t'): - rename(self.errpath, self.path) - else: - rename(self.errpath, '%s.out' % self.path) - - return '.', self.name, '' - + def fail(self, msg): # unittest differentiates between errored and failed. # Failed is denoted by AssertionError (by default at least). raise AssertionError(msg) @@ -1119,7 +1102,7 @@ self.stream.write('~') self.stream.flush() - def addOutputMismatch(self, test, got, expected): + def addOutputMismatch(self, test, ret, got, expected): """Record a mismatch in test output for a particular test.""" if self._options.nodiff: @@ -1138,6 +1121,20 @@ self.stream.write(line) self.stream.flush() + if ret or not self._options.interactive or \ + not os.path.exists(test.errpath): + return + + iolock.acquire() + print 'Accept this change? [n] ', + answer = sys.stdin.readline().strip() + iolock.release() + if answer.lower() in ('y', 'yes'): + if test.name.endswith('.t'): + rename(test.errpath, test.path) + else: + rename(test.errpath, '%s.out' % test.path) + def startTest(self, test): super(TestResult, self).startTest(test) @@ -1524,7 +1521,6 @@ return testcls(refpath, tmpdir, keeptmpdir=self.options.keep_tmpdir, debug=self.options.debug, - interactive=self.options.interactive, timeout=self.options.timeout, startport=self.options.port + count * 3, extraconfigopts=self.options.extra_config_opt,