Show More
@@ -579,6 +579,19 b' def outputcoverage(options):' | |||
|
579 | 579 | os.mkdir(adir) |
|
580 | 580 | covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) |
|
581 | 581 | |
|
582 | class Test(object): | |
|
583 | """Encapsulates a single, runnable test.""" | |
|
584 | ||
|
585 | def __init__(self, path, options): | |
|
586 | self._path = path | |
|
587 | self._options = options | |
|
588 | ||
|
589 | def run(self, testtmp, replacements, env): | |
|
590 | return self._run(testtmp, replacements, env) | |
|
591 | ||
|
592 | def _run(self, testtmp, replacements, env): | |
|
593 | raise NotImplemented('Subclasses must implement Test.run()') | |
|
594 | ||
|
582 | 595 | def pytest(test, wd, options, replacements, env): |
|
583 | 596 | py3kswitch = options.py3k_warnings and ' -3' or '' |
|
584 | 597 | cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test) |
@@ -587,6 +600,11 b' def pytest(test, wd, options, replacemen' | |||
|
587 | 600 | replacements.append((r'\r\n', '\n')) |
|
588 | 601 | return run(cmd, wd, options, replacements, env) |
|
589 | 602 | |
|
603 | class PythonTest(Test): | |
|
604 | """A Python-based test.""" | |
|
605 | def _run(self, testtmp, replacements, env): | |
|
606 | return pytest(self._path, testtmp, self._options, replacements, env) | |
|
607 | ||
|
590 | 608 | needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
|
591 | 609 | escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
|
592 | 610 | escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256)) |
@@ -843,6 +861,12 b' def tsttest(test, wd, options, replaceme' | |||
|
843 | 861 | exitcode = False # set exitcode to warned |
|
844 | 862 | return exitcode, postout |
|
845 | 863 | |
|
864 | class TTest(Test): | |
|
865 | """A "t test" is a test backed by a .t file.""" | |
|
866 | ||
|
867 | def _run(self, testtmp, replacements, env): | |
|
868 | return tsttest(self._path, testtmp, self._options, replacements, env) | |
|
869 | ||
|
846 | 870 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
847 | 871 | def run(cmd, wd, options, replacements, env): |
|
848 | 872 | """Run command in a sub-process, capturing the output (stdout and stderr). |
@@ -952,9 +976,9 b' def runone(options, test, count):' | |||
|
952 | 976 | |
|
953 | 977 | if not os.path.basename(lctest).startswith("test-"): |
|
954 | 978 | return skip("not a test file") |
|
955 |
for ext, |
|
|
979 | for ext, cls, out in testtypes: | |
|
956 | 980 | if lctest.endswith(ext): |
|
957 |
runner = |
|
|
981 | runner = cls | |
|
958 | 982 | ref = os.path.join(TESTDIR, test + out) |
|
959 | 983 | break |
|
960 | 984 | else: |
@@ -965,6 +989,8 b' def runone(options, test, count):' | |||
|
965 | 989 | if os.path.exists(err): |
|
966 | 990 | os.remove(err) # Remove any previous output files |
|
967 | 991 | |
|
992 | t = runner(testpath, options) | |
|
993 | ||
|
968 | 994 | # Make a tmp subdirectory to work in |
|
969 | 995 | threadtmp = os.path.join(HGTMP, "child%d" % count) |
|
970 | 996 | testtmp = os.path.join(threadtmp, os.path.basename(test)) |
@@ -992,7 +1018,7 b' def runone(options, test, count):' | |||
|
992 | 1018 | |
|
993 | 1019 | starttime = time.time() |
|
994 | 1020 | try: |
|
995 |
ret, out = run |
|
|
1021 | ret, out = t.run(testtmp, replacements, env) | |
|
996 | 1022 | except KeyboardInterrupt: |
|
997 | 1023 | endtime = time.time() |
|
998 | 1024 | log('INTERRUPTED: %s (after %d seconds)' % (test, endtime - starttime)) |
@@ -1192,8 +1218,8 b' def runtests(options, tests):' | |||
|
1192 | 1218 | if warned: |
|
1193 | 1219 | return 80 |
|
1194 | 1220 | |
|
1195 |
testtypes = [('.py', |
|
|
1196 |
('.t', |
|
|
1221 | testtypes = [('.py', PythonTest, '.out'), | |
|
1222 | ('.t', TTest, '')] | |
|
1197 | 1223 | |
|
1198 | 1224 | def main(args, parser=None): |
|
1199 | 1225 | parser = parser or getparser() |
General Comments 0
You need to be logged in to leave comments.
Login now