Show More
@@ -731,22 +731,6 b' def globmatch(el, l):' | |||
|
731 | 731 | res += re.escape(c) |
|
732 | 732 | return rematch(res, l) |
|
733 | 733 | |
|
734 | def linematch(el, l): | |
|
735 | if el == l: # perfect match (fast) | |
|
736 | return True | |
|
737 | if el: | |
|
738 | if el.endswith(" (esc)\n"): | |
|
739 | el = el[:-7].decode('string-escape') + '\n' | |
|
740 | if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: | |
|
741 | return True | |
|
742 | if el.endswith(" (re)\n"): | |
|
743 | return rematch(el[:-6], l) | |
|
744 | if el.endswith(" (glob)\n"): | |
|
745 | return globmatch(el[:-8], l) | |
|
746 | if os.altsep and l.replace('\\', '/') == el: | |
|
747 | return '+glob' | |
|
748 | return False | |
|
749 | ||
|
750 | 734 | class TTest(Test): |
|
751 | 735 | """A "t test" is a test backed by a .t file.""" |
|
752 | 736 | |
@@ -919,7 +903,7 b' class TTest(Test):' | |||
|
919 | 903 | if expected.get(pos, None): |
|
920 | 904 | el = expected[pos].pop(0) |
|
921 | 905 | |
|
922 | r = linematch(el, lout) | |
|
906 | r = TTest.linematch(el, lout) | |
|
923 | 907 | if isinstance(r, str): |
|
924 | 908 | if r == '+glob': |
|
925 | 909 | lout = el[:-1] + ' (glob)\n' |
@@ -959,6 +943,23 b' class TTest(Test):' | |||
|
959 | 943 | |
|
960 | 944 | return exitcode, postout |
|
961 | 945 | |
|
946 | @staticmethod | |
|
947 | def linematch(el, l): | |
|
948 | if el == l: # perfect match (fast) | |
|
949 | return True | |
|
950 | if el: | |
|
951 | if el.endswith(" (esc)\n"): | |
|
952 | el = el[:-7].decode('string-escape') + '\n' | |
|
953 | if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: | |
|
954 | return True | |
|
955 | if el.endswith(" (re)\n"): | |
|
956 | return rematch(el[:-6], l) | |
|
957 | if el.endswith(" (glob)\n"): | |
|
958 | return globmatch(el[:-8], l) | |
|
959 | if os.altsep and l.replace('\\', '/') == el: | |
|
960 | return '+glob' | |
|
961 | return False | |
|
962 | ||
|
962 | 963 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
963 | 964 | def run(cmd, wd, options, replacements, env): |
|
964 | 965 | """Run command in a sub-process, capturing the output (stdout and stderr). |
@@ -29,7 +29,7 b' def lm(expected, output):' | |||
|
29 | 29 | assert expected.endswith('\n') and output.endswith('\n'), 'missing newline' |
|
30 | 30 | assert not re.search(r'[^ \w\\/\r\n()*?]', expected + output), \ |
|
31 | 31 | 'single backslash or unknown char' |
|
32 | match = run_tests.linematch(expected, output) | |
|
32 | match = run_tests.TTest.linematch(expected, output) | |
|
33 | 33 | if isinstance(match, str): |
|
34 | 34 | return 'special: ' + match |
|
35 | 35 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now