tests/run-tests.py
branchstable
changeset 857 7060aa668b7f
parent 856 e1a5259b3d03
child 858 ff1badf6ae7a
equal deleted inserted replaced
856:e1a5259b3d03 857:7060aa668b7f
   529 
   529 
   530     pos = -1
   530     pos = -1
   531     postout = []
   531     postout = []
   532     ret = 0
   532     ret = 0
   533     for n, l in enumerate(output):
   533     for n, l in enumerate(output):
   534         if l.startswith(salt):
   534         lout, lcmd = l, None
       
   535         if salt in l:
       
   536             lout, lcmd = l.split(salt, 1)
       
   537 
       
   538         if lout:
       
   539             if lcmd:
       
   540                 lout += ' (no-eol)\n'
       
   541 
       
   542             el = None
       
   543             if pos in expected and expected[pos]:
       
   544                 el = expected[pos].pop(0)
       
   545 
       
   546             if el == lout: # perfect match (fast)
       
   547                 postout.append("  " + lout)
       
   548             elif el and el.decode('string-escape') == l:
       
   549                 postout.append("  " + el)  # \-escape match
       
   550             elif (el and
       
   551                   (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or
       
   552                    el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout))):
       
   553                 postout.append("  " + el) # fallback regex/glob match
       
   554             else:
       
   555                 postout.append("  " + lout) # let diff deal with it
       
   556 
       
   557         if lcmd:
   535             # add on last return code
   558             # add on last return code
   536             ret = int(l.split()[2])
   559             ret = int(lcmd.split()[1])
   537             if ret != 0:
   560             if ret != 0:
   538                 postout.append("  [%s]\n" % ret)
   561                 postout.append("  [%s]\n" % ret)
   539             if pos in after:
   562             if pos in after:
   540                 postout += after.pop(pos)
   563                 postout += after.pop(pos)
   541             pos = int(l.split()[1])
   564             pos = int(lcmd.split()[0])
   542         else:
       
   543             el = None
       
   544             if pos in expected and expected[pos]:
       
   545                 el = expected[pos].pop(0)
       
   546 
       
   547             if el == l: # perfect match (fast)
       
   548                 postout.append("  " + l)
       
   549             elif el and el.decode('string-escape') == l:
       
   550                 postout.append("  " + el)  # \-escape match
       
   551             elif (el and
       
   552                   (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
       
   553                    el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))):
       
   554                 postout.append("  " + el) # fallback regex/glob match
       
   555             else:
       
   556                 postout.append("  " + l) # let diff deal with it
       
   557 
   565 
   558     if pos in after:
   566     if pos in after:
   559         postout += after.pop(pos)
   567         postout += after.pop(pos)
   560 
   568 
   561     return exitcode, postout
   569     return exitcode, postout