Show More
@@ -1073,7 +1073,7 b' def run(cmd, wd, replacements, env, debu' | |||
|
1073 | 1073 | output = re.sub(s, r, output) |
|
1074 | 1074 | return ret, output.splitlines(True) |
|
1075 | 1075 | |
|
1076 | iolock = threading.Lock() | |
|
1076 | iolock = threading.RLock() | |
|
1077 | 1077 | |
|
1078 | 1078 | class SkipTest(Exception): |
|
1079 | 1079 | """Raised to indicate that a test is to be skipped.""" |
@@ -1128,7 +1128,9 b' class TestResult(unittest._TextTestResul' | |||
|
1128 | 1128 | iolock.release() |
|
1129 | 1129 | |
|
1130 | 1130 | def addSuccess(self, test): |
|
1131 | iolock.acquire() | |
|
1131 | 1132 | super(TestResult, self).addSuccess(test) |
|
1133 | iolock.release() | |
|
1132 | 1134 | self.successes.append(test) |
|
1133 | 1135 | |
|
1134 | 1136 | def addError(self, test, err): |
@@ -1139,14 +1141,17 b' class TestResult(unittest._TextTestResul' | |||
|
1139 | 1141 | # Polyfill. |
|
1140 | 1142 | def addSkip(self, test, reason): |
|
1141 | 1143 | self.skipped.append((test, reason)) |
|
1144 | iolock.acquire() | |
|
1142 | 1145 | if self.showAll: |
|
1143 | 1146 | self.stream.writeln('skipped %s' % reason) |
|
1144 | 1147 | else: |
|
1145 | 1148 | self.stream.write('s') |
|
1146 | 1149 | self.stream.flush() |
|
1150 | iolock.release() | |
|
1147 | 1151 | |
|
1148 | 1152 | def addIgnore(self, test, reason): |
|
1149 | 1153 | self.ignored.append((test, reason)) |
|
1154 | iolock.acquire() | |
|
1150 | 1155 | if self.showAll: |
|
1151 | 1156 | self.stream.writeln('ignored %s' % reason) |
|
1152 | 1157 | else: |
@@ -1155,6 +1160,7 b' class TestResult(unittest._TextTestResul' | |||
|
1155 | 1160 | else: |
|
1156 | 1161 | self.testsRun += 1 |
|
1157 | 1162 | self.stream.flush() |
|
1163 | iolock.release() | |
|
1158 | 1164 | |
|
1159 | 1165 | def addWarn(self, test, reason): |
|
1160 | 1166 | self.warned.append((test, reason)) |
@@ -1162,11 +1168,13 b' class TestResult(unittest._TextTestResul' | |||
|
1162 | 1168 | if self._options.first: |
|
1163 | 1169 | self.stop() |
|
1164 | 1170 | |
|
1171 | iolock.acquire() | |
|
1165 | 1172 | if self.showAll: |
|
1166 | 1173 | self.stream.writeln('warned %s' % reason) |
|
1167 | 1174 | else: |
|
1168 | 1175 | self.stream.write('~') |
|
1169 | 1176 | self.stream.flush() |
|
1177 | iolock.release() | |
|
1170 | 1178 | |
|
1171 | 1179 | def addOutputMismatch(self, test, ret, got, expected): |
|
1172 | 1180 | """Record a mismatch in test output for a particular test.""" |
@@ -1231,8 +1239,10 b' class TestResult(unittest._TextTestResul' | |||
|
1231 | 1239 | del self._stopped[test.name] |
|
1232 | 1240 | |
|
1233 | 1241 | if interrupted: |
|
1242 | iolock.acquire() | |
|
1234 | 1243 | self.stream.writeln('INTERRUPTED: %s (after %d seconds)' % ( |
|
1235 | 1244 | test.name, self.times[-1][3])) |
|
1245 | iolock.release() | |
|
1236 | 1246 | |
|
1237 | 1247 | class TestSuite(unittest.TestSuite): |
|
1238 | 1248 | """Custom unitest TestSuite that knows how to execute Mercurial tests.""" |
@@ -1366,6 +1376,7 b' class TextTestRunner(unittest.TextTestRu' | |||
|
1366 | 1376 | skipped = len(result.skipped) |
|
1367 | 1377 | ignored = len(result.ignored) |
|
1368 | 1378 | |
|
1379 | iolock.acquire() | |
|
1369 | 1380 | self.stream.writeln('') |
|
1370 | 1381 | |
|
1371 | 1382 | if not self._runner.options.noskips: |
@@ -1418,9 +1429,12 b' class TextTestRunner(unittest.TextTestRu' | |||
|
1418 | 1429 | if self._runner.options.time: |
|
1419 | 1430 | self.printtimes(result.times) |
|
1420 | 1431 | |
|
1432 | iolock.release() | |
|
1433 | ||
|
1421 | 1434 | return result |
|
1422 | 1435 | |
|
1423 | 1436 | def printtimes(self, times): |
|
1437 | # iolock held by run | |
|
1424 | 1438 | self.stream.writeln('# Producing time report') |
|
1425 | 1439 | times.sort(key=lambda t: (t[3])) |
|
1426 | 1440 | cols = '%7.3f %7.3f %7.3f %s' |
General Comments 0
You need to be logged in to leave comments.
Login now