tests/run-tests.py
branchstable
changeset 777 cd294ce45931
parent 776 1869efbf104d
child 793 9cc90e2c826f
equal deleted inserted replaced
776:1869efbf104d 777:cd294ce45931
   497         vlog("# Running", cmd)
   497         vlog("# Running", cmd)
   498         exitcode, output = run(cmd, options)
   498         exitcode, output = run(cmd, options)
   499     finally:
   499     finally:
   500         os.remove(name)
   500         os.remove(name)
   501 
   501 
       
   502     def rematch(el, l):
       
   503         try:
       
   504             return re.match(el, l)
       
   505         except re.error:
       
   506             # el is an invalid regex
       
   507             return False
       
   508 
   502     pos = -1
   509     pos = -1
   503     postout = []
   510     postout = []
   504     for n, l in enumerate(output):
   511     for n, l in enumerate(output):
   505         if l.startswith(salt):
   512         if l.startswith(salt):
   506             if pos in after:
   513             if pos in after:
   511             if pos in expected and expected[pos]:
   518             if pos in expected and expected[pos]:
   512                 el = expected[pos].pop(0)
   519                 el = expected[pos].pop(0)
   513 
   520 
   514             if el == l: # perfect match (fast)
   521             if el == l: # perfect match (fast)
   515                 postout.append("  " + l)
   522                 postout.append("  " + l)
   516             elif el and re.match(el, l): # fallback regex match
   523             elif el and rematch(el, l): # fallback regex match
   517                 postout.append("  " + el)
   524                 postout.append("  " + el)
   518             else: # mismatch - let diff deal with it
   525             else: # mismatch - let diff deal with it
   519                 postout.append("  " + l)
   526                 postout.append("  " + l)
   520 
   527 
   521     if pos in after:
   528     if pos in after: