tests/run-tests.py
changeset 794 12eadf33cce1
parent 793 9cc90e2c826f
child 795 234c4314c6a4
equal deleted inserted replaced
790:b14093780eaf 794:12eadf33cce1
   472     for n, l in enumerate(t):
   472     for n, l in enumerate(t):
   473         if l.startswith('  $ '): # commands
   473         if l.startswith('  $ '): # commands
   474             after.setdefault(pos, []).append(l)
   474             after.setdefault(pos, []).append(l)
   475             prepos = pos
   475             prepos = pos
   476             pos = n
   476             pos = n
   477             script.append('echo %s %s\n' % (salt, n))
   477             script.append('echo %s %s $?\n' % (salt, n))
   478             script.append(l[4:])
   478             script.append(l[4:])
   479         elif l.startswith('  > '): # continuations
   479         elif l.startswith('  > '): # continuations
   480             after.setdefault(prepos, []).append(l)
   480             after.setdefault(prepos, []).append(l)
   481             script.append(l[4:])
   481             script.append(l[4:])
   482         elif l.startswith('  '): # results
   482         elif l.startswith('  '): # results
   484             expected.setdefault(pos, []).append(l[2:])
   484             expected.setdefault(pos, []).append(l[2:])
   485         else:
   485         else:
   486             # non-command/result - queue up for merged output
   486             # non-command/result - queue up for merged output
   487             after.setdefault(pos, []).append(l)
   487             after.setdefault(pos, []).append(l)
   488 
   488 
       
   489     script.append('echo %s %s $?\n' % (salt, n + 1))
       
   490 
   489     fd, name = tempfile.mkstemp(suffix='hg-tst')
   491     fd, name = tempfile.mkstemp(suffix='hg-tst')
   490 
   492 
   491     try:
   493     try:
   492         for l in script:
   494         for l in script:
   493             os.write(fd, l)
   495             os.write(fd, l)
   506             # el is an invalid regex
   508             # el is an invalid regex
   507             return False
   509             return False
   508 
   510 
   509     pos = -1
   511     pos = -1
   510     postout = []
   512     postout = []
       
   513     ret = 0
   511     for n, l in enumerate(output):
   514     for n, l in enumerate(output):
   512         if l.startswith(salt):
   515         if l.startswith(salt):
       
   516             # add on last return code
       
   517             ret = int(l.split()[2])
       
   518             if ret != 0:
       
   519                 postout.append("  [%s]\n" % ret)
   513             if pos in after:
   520             if pos in after:
   514                 postout += after.pop(pos)
   521                 postout += after.pop(pos)
   515             pos = int(l.split()[1])
   522             pos = int(l.split()[1])
   516         else:
   523         else:
   517             el = None
   524             el = None