tests/run-tests.py
branchstable
changeset 1285 61dfbdf6d67d
parent 1284 3f370565e291
child 1286 545a2ae04b54
equal deleted inserted replaced
1284:3f370565e291 1285:61dfbdf6d67d
   576 
   576 
   577 def pytest(test, wd, options, replacements, env):
   577 def pytest(test, wd, options, replacements, env):
   578     py3kswitch = options.py3k_warnings and ' -3' or ''
   578     py3kswitch = options.py3k_warnings and ' -3' or ''
   579     cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test)
   579     cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test)
   580     vlog("# Running", cmd)
   580     vlog("# Running", cmd)
   581     if os.name == 'nt':
       
   582         replacements.append((r'\r\n', '\n'))
       
   583     return run(cmd, wd, options, replacements, env)
   581     return run(cmd, wd, options, replacements, env)
   584 
   582 
   585 needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search
   583 needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search
   586 escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub
   584 escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub
   587 escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256))
   585 escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256))
   592     return escapesub(escapef, s)
   590     return escapesub(escapef, s)
   593 
   591 
   594 def rematch(el, l):
   592 def rematch(el, l):
   595     try:
   593     try:
   596         # use \Z to ensure that the regex matches to the end of the string
   594         # use \Z to ensure that the regex matches to the end of the string
   597         if os.name == 'nt':
       
   598             return re.match(el + r'\r?\n\Z', l)
       
   599         return re.match(el + r'\n\Z', l)
   595         return re.match(el + r'\n\Z', l)
   600     except re.error:
   596     except re.error:
   601         # el is an invalid regex
   597         # el is an invalid regex
   602         return False
   598         return False
   603 
   599 
   631     if el == l: # perfect match (fast)
   627     if el == l: # perfect match (fast)
   632         return True
   628         return True
   633     if el:
   629     if el:
   634         if el.endswith(" (esc)\n"):
   630         if el.endswith(" (esc)\n"):
   635             el = el[:-7].decode('string-escape') + '\n'
   631             el = el[:-7].decode('string-escape') + '\n'
   636         if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l:
       
   637             return True
       
   638         if (el.endswith(" (re)\n") and rematch(el[:-6], l) or
   632         if (el.endswith(" (re)\n") and rematch(el[:-6], l) or
   639             el.endswith(" (glob)\n") and globmatch(el[:-8], l)):
   633             el.endswith(" (glob)\n") and globmatch(el[:-8], l)):
   640             return True
   634             return True
   641     return False
   635     return False
   642 
   636 
   951             (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
   945             (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
   952                      c in '/\\' and r'[/\\]' or
   946                      c in '/\\' and r'[/\\]' or
   953                      c.isdigit() and c or
   947                      c.isdigit() and c or
   954                      '\\' + c
   948                      '\\' + c
   955                      for c in testtmp), '$TESTTMP'))
   949                      for c in testtmp), '$TESTTMP'))
       
   950         replacements.append((r'\r\n', '\n'))
   956     else:
   951     else:
   957         replacements.append((re.escape(testtmp), '$TESTTMP'))
   952         replacements.append((re.escape(testtmp), '$TESTTMP'))
   958 
   953 
   959     env = createenv(options, testtmp, threadtmp, port)
   954     env = createenv(options, testtmp, threadtmp, port)
   960     createhgrc(env['HGRCPATH'], options)
   955     createhgrc(env['HGRCPATH'], options)