Show More
@@ -695,32 +695,6 def escapef(m): | |||||
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 | |||
@@ -945,6 +919,33 class TTest(Test): | |||||
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 | |
@@ -956,7 +957,7 class TTest(Test): | |||||
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 |
General Comments 0
You need to be logged in to leave comments.
Login now