Show More
@@ -695,16 +695,6 b' def escapef(m):' | |||
|
695 | 695 | def stringescape(s): |
|
696 | 696 | return escapesub(escapef, s) |
|
697 | 697 | |
|
698 | def rematch(el, l): | |
|
699 | try: | |
|
700 | # use \Z to ensure that the regex matches to the end of the string | |
|
701 | if os.name == 'nt': | |
|
702 | return re.match(el + r'\r?\n\Z', l) | |
|
703 | return re.match(el + r'\n\Z', l) | |
|
704 | except re.error: | |
|
705 | # el is an invalid regex | |
|
706 | return False | |
|
707 | ||
|
708 | 698 | def globmatch(el, l): |
|
709 | 699 | # The only supported special characters are * and ? plus / which also |
|
710 | 700 | # matches \ on windows. Escaping of these characters is supported. |
@@ -729,7 +719,7 b' def globmatch(el, l):' | |||
|
729 | 719 | res += '[/\\\\]' |
|
730 | 720 | else: |
|
731 | 721 | res += re.escape(c) |
|
732 | return rematch(res, l) | |
|
722 | return TTest.rematch(res, l) | |
|
733 | 723 | |
|
734 | 724 | class TTest(Test): |
|
735 | 725 | """A "t test" is a test backed by a .t file.""" |
@@ -944,6 +934,17 b' class TTest(Test):' | |||
|
944 | 934 | return exitcode, postout |
|
945 | 935 | |
|
946 | 936 | @staticmethod |
|
937 | def rematch(el, l): | |
|
938 | try: | |
|
939 | # use \Z to ensure that the regex matches to the end of the string | |
|
940 | if os.name == 'nt': | |
|
941 | return re.match(el + r'\r?\n\Z', l) | |
|
942 | return re.match(el + r'\n\Z', l) | |
|
943 | except re.error: | |
|
944 | # el is an invalid regex | |
|
945 | return False | |
|
946 | ||
|
947 | @staticmethod | |
|
947 | 948 | def linematch(el, l): |
|
948 | 949 | if el == l: # perfect match (fast) |
|
949 | 950 | return True |
@@ -953,7 +954,7 b' class TTest(Test):' | |||
|
953 | 954 | if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: |
|
954 | 955 | return True |
|
955 | 956 | if el.endswith(" (re)\n"): |
|
956 | return rematch(el[:-6], l) | |
|
957 | return TTest.rematch(el[:-6], l) | |
|
957 | 958 | if el.endswith(" (glob)\n"): |
|
958 | 959 | return globmatch(el[:-8], l) |
|
959 | 960 | if os.altsep and l.replace('\\', '/') == el: |
General Comments 0
You need to be logged in to leave comments.
Login now