Show More
@@ -543,7 +543,9 b' class Test(unittest.TestCase):' | |||
|
543 | 543 | f.close() |
|
544 | 544 | |
|
545 | 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 | 550 | if ret: |
|
549 | 551 | msg = 'output changed and ' + describe(ret) |
@@ -1084,19 +1086,6 b' class TestResult(unittest._TextTestResul' | |||
|
1084 | 1086 | if not self._options.nodiff: |
|
1085 | 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 | 1089 | self.stream.write('!') |
|
1101 | 1090 | |
|
1102 | 1091 | def addError(self, *args, **kwargs): |
@@ -1140,10 +1129,12 b' class TestResult(unittest._TextTestResul' | |||
|
1140 | 1129 | def addOutputMismatch(self, test, ret, got, expected): |
|
1141 | 1130 | """Record a mismatch in test output for a particular test.""" |
|
1142 | 1131 | |
|
1132 | accepted = False | |
|
1133 | ||
|
1134 | iolock.acquire() | |
|
1143 | 1135 | if self._options.nodiff: |
|
1144 |
|
|
|
1145 | ||
|
1146 | if self._options.view: | |
|
1136 | pass | |
|
1137 | elif self._options.view: | |
|
1147 | 1138 | os.system("%s %s %s" % (self._view, test.refpath, test.errpath)) |
|
1148 | 1139 | else: |
|
1149 | 1140 | failed, lines = getdiff(expected, got, |
@@ -1156,9 +1147,20 b' class TestResult(unittest._TextTestResul' | |||
|
1156 | 1147 | self.stream.write(line) |
|
1157 | 1148 | self.stream.flush() |
|
1158 | 1149 | |
|
1159 | if ret or not self._options.interactive or \ | |
|
1160 | not os.path.exists(test.errpath): | |
|
1161 | return | |
|
1150 | # handle interactive prompt without releasing iolock | |
|
1151 | if self._options.interactive: | |
|
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 | 1165 | def startTest(self, test): |
|
1164 | 1166 | super(TestResult, self).startTest(test) |
@@ -160,9 +160,9 b' Refuse the fix' | |||
|
160 | 160 | $ echo babar |
|
161 | 161 | - rataxes |
|
162 | 162 | + babar |
|
163 | ||
|
163 | Accept this change? [n] | |
|
164 | 164 | ERROR: test-failure.t output changed |
|
165 | Accept this change? [n] !. | |
|
165 | !. | |
|
166 | 166 | Failed test-failure.t: output changed |
|
167 | 167 | # Ran 2 tests, 0 skipped, 0 warned, 1 failed. |
|
168 | 168 | python hash seed: * (glob) |
@@ -182,8 +182,6 b' Accept the fix' | |||
|
182 | 182 | $ echo babar |
|
183 | 183 | - rataxes |
|
184 | 184 | + babar |
|
185 | ||
|
186 | ERROR: test-failure.t output changed | |
|
187 | 185 | Accept this change? [n] .. |
|
188 | 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