Mercurial > hg-stable
changeset 21314:76d7967d8f3d
run-tests: finish moving tsttest() into TTest
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 15:37:50 -0700 |
parents | a2bd02a3b6d2 |
children | 56610da39b48 |
files | tests/run-tests.py |
diffstat | 1 files changed, 62 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Apr 19 15:28:31 2014 -0700 +++ b/tests/run-tests.py Sat Apr 19 15:37:50 2014 -0700 @@ -747,67 +747,6 @@ return '+glob' return False -def tsttest(t, wd, options, salt, after, expected, exitcode, output): - # Merge the script output back into a unified test - - warnonly = 1 # 1: not yet, 2: yes, 3: for sure not - if exitcode != 0: # failure has been reported - warnonly = 3 # set to "for sure not" - pos = -1 - postout = [] - for l in output: - lout, lcmd = l, None - if salt in l: - lout, lcmd = l.split(salt, 1) - - if lout: - if not lout.endswith('\n'): - lout += ' (no-eol)\n' - - # find the expected output at the current position - el = None - if pos in expected and expected[pos]: - el = expected[pos].pop(0) - - r = linematch(el, lout) - if isinstance(r, str): - if r == '+glob': - lout = el[:-1] + ' (glob)\n' - r = '' # warn only this line - elif r == '-glob': - lout = ''.join(el.rsplit(' (glob)', 1)) - r = '' # warn only this line - else: - log('\ninfo, unknown linematch result: %r\n' % r) - r = False - if r: - postout.append(" " + el) - else: - if needescape(lout): - lout = stringescape(lout.rstrip('\n')) + " (esc)\n" - postout.append(" " + lout) # let diff deal with it - if r != '': # if line failed - warnonly = 3 # set to "for sure not" - elif warnonly == 1: # is "not yet" (and line is warn only) - warnonly = 2 # set to "yes" do warn - - if lcmd: - # add on last return code - ret = int(lcmd.split()[1]) - if ret != 0: - postout.append(" [%s]\n" % ret) - if pos in after: - # merge in non-active test bits - postout += after.pop(pos) - pos = int(lcmd.split()[0]) - - if pos in after: - postout += after.pop(pos) - - if warnonly == 2: - exitcode = False # set exitcode to warned - return exitcode, postout - class TTest(Test): """A "t test" is a test backed by a .t file.""" @@ -834,8 +773,7 @@ if exitcode == SKIPPED_STATUS or output is None: return exitcode, output - return tsttest(self, testtmp, self._options, salt, after, expected, - exitcode, output) + return self._processoutput(exitcode, output, salt, after, expected) def _hghave(self, reqs, testtmp): # TODO do something smarter when all other uses of hghave are gone. @@ -959,6 +897,67 @@ return salt, script, after, expected + def _processoutput(self, exitcode, output, salt, after, expected): + # Merge the script output back into a unified test. + warnonly = 1 # 1: not yet; 2: yes; 3: for sure not + if exitcode != 0: + warnonly = 3 + + pos = -1 + postout = [] + for l in output: + lout, lcmd = l, None + if salt in l: + lout, lcmd = l.split(salt, 1) + + if lout: + if not lout.endswith('\n'): + lout += ' (no-eol)\n' + + # Find the expected output at the current position. + el = None + if expected.get(pos, None): + el = expected[pos].pop(0) + + r = linematch(el, lout) + if isinstance(r, str): + if r == '+glob': + lout = el[:-1] + ' (glob)\n' + r = '' # Warn only this line. + elif r == '-glob': + lout = ''.join(el.rsplit(' (glob)', 1)) + r = '' # Warn only this line. + else: + log('\ninfo, unknown linematch result: %r\n' % r) + r = False + if r: + postout.append(' ' + el) + else: + if needescape(lout): + lout = stringescape(lout.rstrip('\n')) + ' (esc)\n' + postout.append(' ' + lout) # Let diff deal with it. + if r != '': # If line failed. + warnonly = 3 # for sure not + elif warnonly == 1: # Is "not yet" and line is warn only. + warnonly = 2 # Yes do warn. + + if lcmd: + # Add on last return code. + ret = int(lcmd.split()[1]) + if ret != 0: + postout.append(' [%s]\n' % ret) + if pos in after: + # Merge in non-active test bits. + postout += after.pop(pos) + pos = int(lcmd.split()[0]) + + if pos in after: + postout += after.pop(pos) + + if warnonly == 2: + exitcode = False # Set exitcode to warned. + + return exitcode, postout wifexited = getattr(os, "WIFEXITED", lambda x: False) def run(cmd, wd, options, replacements, env):