equal
deleted
inserted
replaced
693 def escapef(m): |
693 def escapef(m): |
694 return escapemap[m.group(0)] |
694 return escapemap[m.group(0)] |
695 def stringescape(s): |
695 def stringescape(s): |
696 return escapesub(escapef, s) |
696 return escapesub(escapef, s) |
697 |
697 |
698 def globmatch(el, l): |
|
699 # The only supported special characters are * and ? plus / which also |
|
700 # matches \ on windows. Escaping of these characters is supported. |
|
701 if el + '\n' == l: |
|
702 if os.altsep: |
|
703 # matching on "/" is not needed for this line |
|
704 return '-glob' |
|
705 return True |
|
706 i, n = 0, len(el) |
|
707 res = '' |
|
708 while i < n: |
|
709 c = el[i] |
|
710 i += 1 |
|
711 if c == '\\' and el[i] in '*?\\/': |
|
712 res += el[i - 1:i + 1] |
|
713 i += 1 |
|
714 elif c == '*': |
|
715 res += '.*' |
|
716 elif c == '?': |
|
717 res += '.' |
|
718 elif c == '/' and os.altsep: |
|
719 res += '[/\\\\]' |
|
720 else: |
|
721 res += re.escape(c) |
|
722 return TTest.rematch(res, l) |
|
723 |
|
724 class TTest(Test): |
698 class TTest(Test): |
725 """A "t test" is a test backed by a .t file.""" |
699 """A "t test" is a test backed by a .t file.""" |
726 |
700 |
727 def _run(self, testtmp, replacements, env): |
701 def _run(self, testtmp, replacements, env): |
728 f = open(self._path) |
702 f = open(self._path) |
943 except re.error: |
917 except re.error: |
944 # el is an invalid regex |
918 # el is an invalid regex |
945 return False |
919 return False |
946 |
920 |
947 @staticmethod |
921 @staticmethod |
|
922 def globmatch(el, l): |
|
923 # The only supported special characters are * and ? plus / which also |
|
924 # matches \ on windows. Escaping of these characters is supported. |
|
925 if el + '\n' == l: |
|
926 if os.altsep: |
|
927 # matching on "/" is not needed for this line |
|
928 return '-glob' |
|
929 return True |
|
930 i, n = 0, len(el) |
|
931 res = '' |
|
932 while i < n: |
|
933 c = el[i] |
|
934 i += 1 |
|
935 if c == '\\' and el[i] in '*?\\/': |
|
936 res += el[i - 1:i + 1] |
|
937 i += 1 |
|
938 elif c == '*': |
|
939 res += '.*' |
|
940 elif c == '?': |
|
941 res += '.' |
|
942 elif c == '/' and os.altsep: |
|
943 res += '[/\\\\]' |
|
944 else: |
|
945 res += re.escape(c) |
|
946 return TTest.rematch(res, l) |
|
947 |
|
948 @staticmethod |
948 def linematch(el, l): |
949 def linematch(el, l): |
949 if el == l: # perfect match (fast) |
950 if el == l: # perfect match (fast) |
950 return True |
951 return True |
951 if el: |
952 if el: |
952 if el.endswith(" (esc)\n"): |
953 if el.endswith(" (esc)\n"): |
954 if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: |
955 if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: |
955 return True |
956 return True |
956 if el.endswith(" (re)\n"): |
957 if el.endswith(" (re)\n"): |
957 return TTest.rematch(el[:-6], l) |
958 return TTest.rematch(el[:-6], l) |
958 if el.endswith(" (glob)\n"): |
959 if el.endswith(" (glob)\n"): |
959 return globmatch(el[:-8], l) |
960 return TTest.globmatch(el[:-8], l) |
960 if os.altsep and l.replace('\\', '/') == el: |
961 if os.altsep and l.replace('\\', '/') == el: |
961 return '+glob' |
962 return '+glob' |
962 return False |
963 return False |
963 |
964 |
964 wifexited = getattr(os, "WIFEXITED", lambda x: False) |
965 wifexited = getattr(os, "WIFEXITED", lambda x: False) |