tests/run-tests.py
changeset 17777 af7c6bc48d8d
parent 17751 4871c1f343fa
child 17778 80fe64581f3a
equal deleted inserted replaced
17776:072812e9f570 17777:af7c6bc48d8d
   492 def stringescape(s):
   492 def stringescape(s):
   493     return escapesub(escapef, s)
   493     return escapesub(escapef, s)
   494 
   494 
   495 def rematch(el, l):
   495 def rematch(el, l):
   496     try:
   496     try:
   497         # ensure that the regex matches to the end of the string
   497         # use \Z to ensure that the regex matches to the end of the string
   498         return re.match(el + r'\Z', l)
   498         if os.name == 'nt':
       
   499             return re.match(el + r'\r?\n\Z', l)
       
   500         return re.match(el + r'\n\Z', l)
   499     except re.error:
   501     except re.error:
   500         # el is an invalid regex
   502         # el is an invalid regex
   501         return False
   503         return False
   502 
   504 
   503 def globmatch(el, l):
   505 def globmatch(el, l):
   523 
   525 
   524 def linematch(el, l):
   526 def linematch(el, l):
   525     if el == l: # perfect match (fast)
   527     if el == l: # perfect match (fast)
   526         return True
   528         return True
   527     if (el and
   529     if (el and
   528         (el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or
   530         (el.endswith(" (re)\n") and rematch(el[:-6], l) or
   529          el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l) or
   531          el.endswith(" (glob)\n") and globmatch(el[:-8], l) or
   530          el.endswith(" (esc)\n") and
   532          el.endswith(" (esc)\n") and
   531              (el[:-7].decode('string-escape') + '\n' == l or
   533              (el[:-7].decode('string-escape') + '\n' == l or
   532               el[:-7].decode('string-escape').replace('\r', '') +
   534               os.name == 'nt' and
   533                   '\n' == l and os.name == 'nt'))):
   535               el[:-7].decode('string-escape') + '\n' == l))):
   534         return True
   536         return True
   535     return False
   537     return False
   536 
   538 
   537 def tsttest(test, wd, options, replacements):
   539 def tsttest(test, wd, options, replacements):
   538     # We generate a shell script which outputs unique markers to line
   540     # We generate a shell script which outputs unique markers to line
   883         (r':%s\b' % options.port, ':$HGPORT'),
   885         (r':%s\b' % options.port, ':$HGPORT'),
   884         (r':%s\b' % (options.port + 1), ':$HGPORT1'),
   886         (r':%s\b' % (options.port + 1), ':$HGPORT1'),
   885         (r':%s\b' % (options.port + 2), ':$HGPORT2'),
   887         (r':%s\b' % (options.port + 2), ':$HGPORT2'),
   886         ]
   888         ]
   887     if os.name == 'nt':
   889     if os.name == 'nt':
   888         replacements.append((r'\r\n', '\n'))
       
   889         replacements.append(
   890         replacements.append(
   890             (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
   891             (''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or
   891                      c in '/\\' and r'[/\\]' or
   892                      c in '/\\' and r'[/\\]' or
   892                      c.isdigit() and c or
   893                      c.isdigit() and c or
   893                      '\\' + c
   894                      '\\' + c