tests/run-tests.py
changeset 1322 95880c8fedb6
parent 1321 79f68c0ed71e
child 1327 953d562c3ebf
equal deleted inserted replaced
1314:48123437bbc5 1322:95880c8fedb6
   604     # The only supported special characters are * and ? plus / which also
   604     # The only supported special characters are * and ? plus / which also
   605     # matches \ on windows. Escaping of these caracters is supported.
   605     # matches \ on windows. Escaping of these caracters is supported.
   606     if el + '\n' == l:
   606     if el + '\n' == l:
   607         if os.altsep:
   607         if os.altsep:
   608             # matching on "/" is not needed for this line
   608             # matching on "/" is not needed for this line
   609             log("\nInfo, unnecessary glob: %s (glob)" % el)
   609             return '-glob'
   610         return True
   610         return True
   611     i, n = 0, len(el)
   611     i, n = 0, len(el)
   612     res = ''
   612     res = ''
   613     while i < n:
   613     while i < n:
   614         c = el[i]
   614         c = el[i]
   632     if el:
   632     if el:
   633         if el.endswith(" (esc)\n"):
   633         if el.endswith(" (esc)\n"):
   634             el = el[:-7].decode('string-escape') + '\n'
   634             el = el[:-7].decode('string-escape') + '\n'
   635         if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l:
   635         if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l:
   636             return True
   636             return True
   637         if (el.endswith(" (re)\n") and rematch(el[:-6], l) or
   637         if el.endswith(" (re)\n"):
   638             el.endswith(" (glob)\n") and globmatch(el[:-8], l)):
   638             return rematch(el[:-6], l)
   639             return True
   639         if el.endswith(" (glob)\n"):
       
   640             return globmatch(el[:-8], l)
       
   641         if os.altsep and l.replace('\\', '/') == el:
       
   642             return '+glob'
   640     return False
   643     return False
   641 
   644 
   642 def tsttest(test, wd, options, replacements, env):
   645 def tsttest(test, wd, options, replacements, env):
   643     # We generate a shell script which outputs unique markers to line
   646     # We generate a shell script which outputs unique markers to line
   644     # up script results with our source. These markers include input
   647     # up script results with our source. These markers include input
   788             # find the expected output at the current position
   791             # find the expected output at the current position
   789             el = None
   792             el = None
   790             if pos in expected and expected[pos]:
   793             if pos in expected and expected[pos]:
   791                 el = expected[pos].pop(0)
   794                 el = expected[pos].pop(0)
   792 
   795 
   793             if linematch(el, lout):
   796             r = linematch(el, lout)
       
   797             if isinstance(r, str):
       
   798                 if r == '+glob':
       
   799                     lout = el[:-1] + ' (glob)\n'
       
   800                     r = False
       
   801                 elif r == '-glob':
       
   802                     log('\ninfo, unnecessary glob in %s (after line %d):'
       
   803                         ' %s (glob)\n' % (test, pos, el[-1]))
       
   804                     r = True # pass on unnecessary glob
       
   805                 else:
       
   806                     log('\ninfo, unknown linematch result: %r\n' % r)
       
   807                     r = False
       
   808             if r:
   794                 postout.append("  " + el)
   809                 postout.append("  " + el)
   795             else:
   810             else:
   796                 if needescape(lout):
   811                 if needescape(lout):
   797                     lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
   812                     lout = stringescape(lout.rstrip('\n')) + " (esc)\n"
   798                 postout.append("  " + lout) # let diff deal with it
   813                 postout.append("  " + lout) # let diff deal with it
  1075     def job(test, count):
  1090     def job(test, count):
  1076         try:
  1091         try:
  1077             done.put(runone(options, test, count))
  1092             done.put(runone(options, test, count))
  1078         except KeyboardInterrupt:
  1093         except KeyboardInterrupt:
  1079             pass
  1094             pass
       
  1095         except: # re-raises
       
  1096             done.put(('!', test, 'run-test raised an error, see traceback'))
       
  1097             raise
  1080 
  1098 
  1081     try:
  1099     try:
  1082         while tests or running:
  1100         while tests or running:
  1083             if not done.empty() or running == jobs or not tests:
  1101             if not done.empty() or running == jobs or not tests:
  1084                 try:
  1102                 try:
  1091                 running -= 1
  1109                 running -= 1
  1092             if tests and not running == jobs:
  1110             if tests and not running == jobs:
  1093                 test = tests.pop(0)
  1111                 test = tests.pop(0)
  1094                 if options.loop:
  1112                 if options.loop:
  1095                     tests.append(test)
  1113                     tests.append(test)
  1096                 t = threading.Thread(target=job, args=(test, count))
  1114                 t = threading.Thread(target=job, name=test, args=(test, count))
  1097                 t.start()
  1115                 t.start()
  1098                 running += 1
  1116                 running += 1
  1099                 count += 1
  1117                 count += 1
  1100     except KeyboardInterrupt:
  1118     except KeyboardInterrupt:
  1101         abort = True
  1119         abort = True