##// END OF EJS Templates
run-tests: hold iolock across diff/prompt when interactive...
Matt Mackall -
r21763:84cd5ee7 default
parent child Browse files
Show More
@@ -543,7 +543,9 b' class Test(unittest.TestCase):'
543 f.close()
543 f.close()
544
544
545 # The result object handles diff calculation for us.
545 # The result object handles diff calculation for us.
546 self._result.addOutputMismatch(self, ret, out, self._refout)
546 if self._result.addOutputMismatch(self, ret, out, self._refout):
547 # change was accepted, skip failing
548 return
547
549
548 if ret:
550 if ret:
549 msg = 'output changed and ' + describe(ret)
551 msg = 'output changed and ' + describe(ret)
@@ -1084,19 +1086,6 b' class TestResult(unittest._TextTestResul'
1084 if not self._options.nodiff:
1086 if not self._options.nodiff:
1085 self.stream.write('\nERROR: %s output changed\n' % test)
1087 self.stream.write('\nERROR: %s output changed\n' % test)
1086
1088
1087 if self._options.interactive:
1088 iolock.acquire()
1089 self.stream.write('Accept this change? [n] ')
1090 answer = sys.stdin.readline().strip()
1091 iolock.release()
1092 if answer.lower() in ('y', 'yes'):
1093 if test.name.endswith('.t'):
1094 rename(test.errpath, test.path)
1095 else:
1096 rename(test.errpath, '%s.out' % test.path)
1097 self.failures.pop()
1098 return 1
1099
1100 self.stream.write('!')
1089 self.stream.write('!')
1101
1090
1102 def addError(self, *args, **kwargs):
1091 def addError(self, *args, **kwargs):
@@ -1140,10 +1129,12 b' class TestResult(unittest._TextTestResul'
1140 def addOutputMismatch(self, test, ret, got, expected):
1129 def addOutputMismatch(self, test, ret, got, expected):
1141 """Record a mismatch in test output for a particular test."""
1130 """Record a mismatch in test output for a particular test."""
1142
1131
1132 accepted = False
1133
1134 iolock.acquire()
1143 if self._options.nodiff:
1135 if self._options.nodiff:
1144 return
1136 pass
1145
1137 elif self._options.view:
1146 if self._options.view:
1147 os.system("%s %s %s" % (self._view, test.refpath, test.errpath))
1138 os.system("%s %s %s" % (self._view, test.refpath, test.errpath))
1148 else:
1139 else:
1149 failed, lines = getdiff(expected, got,
1140 failed, lines = getdiff(expected, got,
@@ -1156,9 +1147,20 b' class TestResult(unittest._TextTestResul'
1156 self.stream.write(line)
1147 self.stream.write(line)
1157 self.stream.flush()
1148 self.stream.flush()
1158
1149
1159 if ret or not self._options.interactive or \
1150 # handle interactive prompt without releasing iolock
1160 not os.path.exists(test.errpath):
1151 if self._options.interactive:
1161 return
1152 self.stream.write('Accept this change? [n] ')
1153 answer = sys.stdin.readline().strip()
1154 if answer.lower() in ('y', 'yes'):
1155 if test.name.endswith('.t'):
1156 rename(test.errpath, test.path)
1157 else:
1158 rename(test.errpath, '%s.out' % test.path)
1159 accepted = True
1160
1161 iolock.release()
1162
1163 return accepted
1162
1164
1163 def startTest(self, test):
1165 def startTest(self, test):
1164 super(TestResult, self).startTest(test)
1166 super(TestResult, self).startTest(test)
@@ -160,9 +160,9 b' Refuse the fix'
160 $ echo babar
160 $ echo babar
161 - rataxes
161 - rataxes
162 + babar
162 + babar
163
163 Accept this change? [n]
164 ERROR: test-failure.t output changed
164 ERROR: test-failure.t output changed
165 Accept this change? [n] !.
165 !.
166 Failed test-failure.t: output changed
166 Failed test-failure.t: output changed
167 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
167 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
168 python hash seed: * (glob)
168 python hash seed: * (glob)
@@ -182,8 +182,6 b' Accept the fix'
182 $ echo babar
182 $ echo babar
183 - rataxes
183 - rataxes
184 + babar
184 + babar
185
186 ERROR: test-failure.t output changed
187 Accept this change? [n] ..
185 Accept this change? [n] ..
188 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
186 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
189
187
General Comments 0
You need to be logged in to leave comments. Login now