tests/run-tests.py
branchstable
changeset 1002 9a8202faebb3
parent 1001 21b3c555b6f4
child 1003 59bd7f017103
equal deleted inserted replaced
1001:21b3c555b6f4 1002:9a8202faebb3
   546             res += '.'
   546             res += '.'
   547         else:
   547         else:
   548             res += re.escape(c)
   548             res += re.escape(c)
   549     return rematch(res, l)
   549     return rematch(res, l)
   550 
   550 
       
   551 def linematch(el, l):
       
   552     if el == l: # perfect match (fast)
       
   553         return True
       
   554     if (el and
       
   555         (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
       
   556          el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or
       
   557          el.endswith(" (esc)\n") and el.decode('string-escape') == l)):
       
   558         return True
       
   559     return False
       
   560 
   551 def tsttest(test, wd, options, replacements):
   561 def tsttest(test, wd, options, replacements):
   552     t = open(test)
   562     t = open(test)
   553     out = []
   563     out = []
   554     script = []
   564     script = []
   555 
   565 
   653             # find the expected output at the current position
   663             # find the expected output at the current position
   654             el = None
   664             el = None
   655             if pos in expected and expected[pos]:
   665             if pos in expected and expected[pos]:
   656                 el = expected[pos].pop(0)
   666                 el = expected[pos].pop(0)
   657 
   667 
   658             if el == lout: # perfect match (fast)
   668             if linematch(el, lout):
   659                 postout.append("  " + lout)
   669                 postout.append("  " + el)
   660             elif (el and
       
   661                   (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', lout) or
       
   662                    el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', lout)
       
   663                    or el.endswith(" (esc)\n") and
       
   664                       el.decode('string-escape') == l)):
       
   665                 postout.append("  " + el) # fallback regex/glob/esc match
       
   666             else:
   670             else:
   667                 if needescape(lout):
   671                 if needescape(lout):
   668                     lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
   672                     lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
   669                 postout.append("  " + lout) # let diff deal with it
   673                 postout.append("  " + lout) # let diff deal with it
   670 
   674