##// END OF EJS Templates
run-tests: alternative way of handling \r on Windows...
Mads Kiilerich -
r17777:af7c6bc4 default
parent child Browse files
Show More
@@ -494,8 +494,10 b' def stringescape(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
@@ -525,12 +527,12 b' 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
@@ -885,7 +887,6 b' def runone(options, test):'
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
@@ -52,6 +52,16 b' Literal match ending in " (re)":'
52 $ echo 'foo (re)'
52 $ echo 'foo (re)'
53 foo (re)
53 foo (re)
54
54
55 Windows: \r\n is handled like \n and can be escaped:
56
57 #if windows
58 $ printf 'crlf\r\ncr\r\tcrlf\r\ncrcrlf\r\r\n'
59 crlf
60 cr\r (no-eol) (esc)
61 \tcrlf (esc)
62 crcrlf\r (esc)
63 #endif
64
55 testing hghave
65 testing hghave
56
66
57 $ "$TESTDIR/hghave" true
67 $ "$TESTDIR/hghave" true
General Comments 0
You need to be logged in to leave comments. Login now