##// END OF EJS Templates
run-tests: make linematch a static method of TTest...
Gregory Szorc -
r21315:56610da3 default
parent child Browse files
Show More
@@ -731,22 +731,6 b' def globmatch(el, l):'
731 res += re.escape(c)
731 res += re.escape(c)
732 return rematch(res, l)
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 class TTest(Test):
734 class TTest(Test):
751 """A "t test" is a test backed by a .t file."""
735 """A "t test" is a test backed by a .t file."""
752
736
@@ -919,7 +903,7 b' class TTest(Test):'
919 if expected.get(pos, None):
903 if expected.get(pos, None):
920 el = expected[pos].pop(0)
904 el = expected[pos].pop(0)
921
905
922 r = linematch(el, lout)
906 r = TTest.linematch(el, lout)
923 if isinstance(r, str):
907 if isinstance(r, str):
924 if r == '+glob':
908 if r == '+glob':
925 lout = el[:-1] + ' (glob)\n'
909 lout = el[:-1] + ' (glob)\n'
@@ -959,6 +943,23 b' class TTest(Test):'
959
943
960 return exitcode, postout
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 wifexited = getattr(os, "WIFEXITED", lambda x: False)
963 wifexited = getattr(os, "WIFEXITED", lambda x: False)
963 def run(cmd, wd, options, replacements, env):
964 def run(cmd, wd, options, replacements, env):
964 """Run command in a sub-process, capturing the output (stdout and stderr).
965 """Run command in a sub-process, capturing the output (stdout and stderr).
@@ -29,7 +29,7 b' def lm(expected, output):'
29 assert expected.endswith('\n') and output.endswith('\n'), 'missing newline'
29 assert expected.endswith('\n') and output.endswith('\n'), 'missing newline'
30 assert not re.search(r'[^ \w\\/\r\n()*?]', expected + output), \
30 assert not re.search(r'[^ \w\\/\r\n()*?]', expected + output), \
31 'single backslash or unknown char'
31 'single backslash or unknown char'
32 match = run_tests.linematch(expected, output)
32 match = run_tests.TTest.linematch(expected, output)
33 if isinstance(match, str):
33 if isinstance(match, str):
34 return 'special: ' + match
34 return 'special: ' + match
35 else:
35 else:
General Comments 0
You need to be logged in to leave comments. Login now