Show More
@@ -927,26 +927,6 b' class TTest(Test):' | |||||
927 | return '+glob' |
|
927 | return '+glob' | |
928 | return False |
|
928 | return False | |
929 |
|
929 | |||
930 | def gettest(runner, test, count): |
|
|||
931 | """Obtain a Test by looking at its filename. |
|
|||
932 |
|
||||
933 | Returns a Test instance. The Test may not be runnable if it doesn't map |
|
|||
934 | to a known type. |
|
|||
935 | """ |
|
|||
936 |
|
||||
937 | lctest = test.lower() |
|
|||
938 | refpath = os.path.join(runner.testdir, test) |
|
|||
939 |
|
||||
940 | testcls = Test |
|
|||
941 |
|
||||
942 | for ext, cls, out in testtypes: |
|
|||
943 | if lctest.endswith(ext): |
|
|||
944 | testcls = cls |
|
|||
945 | refpath = os.path.join(runner.testdir, test + out) |
|
|||
946 | break |
|
|||
947 |
|
||||
948 | return testcls(runner, test, count, refpath) |
|
|||
949 |
|
||||
950 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
930 | wifexited = getattr(os, "WIFEXITED", lambda x: False) | |
951 | def run(cmd, wd, options, replacements, env): |
|
931 | def run(cmd, wd, options, replacements, env): | |
952 | """Run command in a sub-process, capturing the output (stdout and stderr). |
|
932 | """Run command in a sub-process, capturing the output (stdout and stderr). | |
@@ -1024,7 +1004,7 b' def scheduletests(runner, tests):' | |||||
1024 |
|
1004 | |||
1025 | def job(test, count): |
|
1005 | def job(test, count): | |
1026 | try: |
|
1006 | try: | |
1027 |
t = gettest( |
|
1007 | t = runner.gettest(test, count) | |
1028 | done.put(t.run()) |
|
1008 | done.put(t.run()) | |
1029 | t.cleanup() |
|
1009 | t.cleanup() | |
1030 | except KeyboardInterrupt: |
|
1010 | except KeyboardInterrupt: | |
@@ -1108,14 +1088,17 b' def runtests(runner, tests):' | |||||
1108 | if warned: |
|
1088 | if warned: | |
1109 | return 80 |
|
1089 | return 80 | |
1110 |
|
1090 | |||
1111 | testtypes = [('.py', PythonTest, '.out'), |
|
|||
1112 | ('.t', TTest, '')] |
|
|||
1113 |
|
||||
1114 | class TestRunner(object): |
|
1091 | class TestRunner(object): | |
1115 | """Holds context for executing tests. |
|
1092 | """Holds context for executing tests. | |
1116 |
|
1093 | |||
1117 | Tests rely on a lot of state. This object holds it for them. |
|
1094 | Tests rely on a lot of state. This object holds it for them. | |
1118 | """ |
|
1095 | """ | |
|
1096 | ||||
|
1097 | TESTTYPES = [ | |||
|
1098 | ('.py', PythonTest, '.out'), | |||
|
1099 | ('.t', TTest, ''), | |||
|
1100 | ] | |||
|
1101 | ||||
1119 | def __init__(self): |
|
1102 | def __init__(self): | |
1120 | self.options = None |
|
1103 | self.options = None | |
1121 | self.testdir = None |
|
1104 | self.testdir = None | |
@@ -1127,6 +1110,25 b' class TestRunner(object):' | |||||
1127 | self.coveragefile = None |
|
1110 | self.coveragefile = None | |
1128 | self._createdfiles = [] |
|
1111 | self._createdfiles = [] | |
1129 |
|
1112 | |||
|
1113 | def gettest(self, test, count): | |||
|
1114 | """Obtain a Test by looking at its filename. | |||
|
1115 | ||||
|
1116 | Returns a Test instance. The Test may not be runnable if it doesn't | |||
|
1117 | map to a known type. | |||
|
1118 | """ | |||
|
1119 | lctest = test.lower() | |||
|
1120 | refpath = os.path.join(self.testdir, test) | |||
|
1121 | ||||
|
1122 | testcls = Test | |||
|
1123 | ||||
|
1124 | for ext, cls, out in self.TESTTYPES: | |||
|
1125 | if lctest.endswith(ext): | |||
|
1126 | testcls = cls | |||
|
1127 | refpath = os.path.join(self.testdir, test + out) | |||
|
1128 | break | |||
|
1129 | ||||
|
1130 | return testcls(self, test, count, refpath) | |||
|
1131 | ||||
1130 | def cleanup(self): |
|
1132 | def cleanup(self): | |
1131 | """Clean up state from this test invocation.""" |
|
1133 | """Clean up state from this test invocation.""" | |
1132 |
|
1134 |
General Comments 0
You need to be logged in to leave comments.
Login now