| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import test_env # pylint: disable=W0611 | 6 import test_env # pylint: disable=W0611 |
| 7 import unittest | 7 import unittest |
| 8 import mock | 8 import mock |
| 9 | 9 |
| 10 from buildbot.status.builder import FAILURE, SUCCESS | 10 from buildbot.status.builder import FAILURE, SUCCESS |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 TEST_STATUS_MULTI_IMPROVE = ( | 39 TEST_STATUS_MULTI_IMPROVE = ( |
| 40 'media_tests_av_perf <div class="BuildResultInfo"> PERF_IMPROVE: time/t ' | 40 'media_tests_av_perf <div class="BuildResultInfo"> PERF_IMPROVE: time/t ' |
| 41 '(89.07%), fps/video (5.40%), fps/video2 (5.40%) </div>') | 41 '(89.07%), fps/video (5.40%), fps/video2 (5.40%) </div>') |
| 42 | 42 |
| 43 TEST_STATUS_MULTI_REGRESS_IMPROVE = ( | 43 TEST_STATUS_MULTI_REGRESS_IMPROVE = ( |
| 44 'media_tests_av_perf <div class="BuildResultInfo"> PERF_REGRESS: time/t ' | 44 'media_tests_av_perf <div class="BuildResultInfo"> PERF_REGRESS: time/t ' |
| 45 '(89.07%), fps/video (5.40%), fps/video2 (5.40%) PERF_IMPROVE: cpu/t ' | 45 '(89.07%), fps/video (5.40%), fps/video2 (5.40%) PERF_IMPROVE: cpu/t ' |
| 46 '(44.07%), cpu/t2 (3.0%) </div>') | 46 '(44.07%), cpu/t2 (3.0%) </div>') |
| 47 | 47 |
| 48 | 48 |
| 49 def getBuildStatusMock(name): |
| 50 """Mocks a build status with a name as the parameter.""" |
| 51 build_status = mock.Mock() |
| 52 build_status.getName.return_value = name |
| 53 build_status.getSourceStamp.return_value = None |
| 54 build_status.getResponsibleUsers.return_value = '' |
| 55 build_status.getChanges.return_value = '' |
| 56 return build_status |
| 57 |
| 58 |
| 49 class PerfCountNotifierTest(unittest.TestCase): | 59 class PerfCountNotifierTest(unittest.TestCase): |
| 50 | 60 |
| 51 def setUp(self): | 61 def setUp(self): |
| 52 self.email_sent = False | 62 self.email_sent = False |
| 53 self.notifier = PerfCountNotifier( | 63 self.notifier = PerfCountNotifier( |
| 54 fromaddr='buildbot@test', | 64 fromaddr='buildbot@test', |
| 55 forgiving_steps=[], | 65 forgiving_steps=[], |
| 56 lookup='test', | 66 lookup='test', |
| 57 sendToInterestedUsers=False, | 67 sendToInterestedUsers=False, |
| 58 extraRecipients=['extra@test'], | 68 extraRecipients=['extra@test'], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 self.old_getName = ChromiumNotifier.getName | 79 self.old_getName = ChromiumNotifier.getName |
| 70 ChromiumNotifier.getName = self.getNameMock | 80 ChromiumNotifier.getName = self.getNameMock |
| 71 | 81 |
| 72 def resetMockDefaultFunctions(self): | 82 def resetMockDefaultFunctions(self): |
| 73 ChromiumNotifier.getName = self.old_getName | 83 ChromiumNotifier.getName = self.old_getName |
| 74 | 84 |
| 75 def getNameMock(self, step_status): | 85 def getNameMock(self, step_status): |
| 76 """Mocks the getName which returns the build_status step name.""" | 86 """Mocks the getName which returns the build_status step name.""" |
| 77 return self.notifier.step_names[0] | 87 return self.notifier.step_names[0] |
| 78 | 88 |
| 89 def getResultCount(self, result_name): |
| 90 """Returns the number of times result_name has been stored.""" |
| 91 return self.notifier.recent_results.GetCount(result_name) |
| 92 |
| 79 def testSuccessIsNotInteresting(self): | 93 def testSuccessIsNotInteresting(self): |
| 80 """Test success step is not interesting.""" | 94 """Test success step is not interesting.""" |
| 81 build_status = None | 95 build_status = getBuildStatusMock('test_build') |
| 82 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 96 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 83 results = [SUCCESS] | 97 results = [SUCCESS] |
| 84 for _ in range(self.notifier.minimum_count): | 98 for _ in range(self.notifier.minimum_count): |
| 85 self.assertFalse(self.notifier.isInterestingStep( | 99 self.assertFalse(self.notifier.isInterestingStep( |
| 86 build_status, step_status, results)) | 100 build_status, step_status, results)) |
| 87 | 101 |
| 88 def testIsInterestingAfterMinimumResults(self): | 102 def testIsInterestingAfterMinimumResults(self): |
| 89 """Test step is interesting only after minimum consecutive results.""" | 103 """Test step is interesting only after minimum consecutive results.""" |
| 90 build_status = None | 104 build_status = getBuildStatusMock('test_build') |
| 91 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 105 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 92 results = [FAILURE] | 106 results = [FAILURE] |
| 93 for _ in range(self.notifier.minimum_count - 1): | 107 for _ in range(self.notifier.minimum_count - 1): |
| 94 self.assertFalse(self.notifier.isInterestingStep( | 108 self.assertFalse(self.notifier.isInterestingStep( |
| 95 build_status, step_status, results)) | 109 build_status, step_status, results)) |
| 96 self.assertTrue(self.notifier.isInterestingStep( | 110 self.assertTrue(self.notifier.isInterestingStep( |
| 97 build_status, step_status, results)) | 111 build_status, step_status, results)) |
| 98 | 112 |
| 99 def testIsInterestingResetByCounterResults(self): | 113 def testIsInterestingResetByCounterResults(self): |
| 100 """Test step is not interesting if a counter result appears.""" | 114 """Test step is not interesting if a counter result appears.""" |
| 101 build_status = None | 115 build_status = getBuildStatusMock('test_build') |
| 102 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 116 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 103 results = [FAILURE] | 117 results = [FAILURE] |
| 104 for _ in range(self.notifier.minimum_count - 1): | 118 for _ in range(self.notifier.minimum_count - 1): |
| 105 self.assertFalse(self.notifier.isInterestingStep( | 119 self.assertFalse(self.notifier.isInterestingStep( |
| 106 build_status, step_status, results)) | 120 build_status, step_status, results)) |
| 107 # Reset the counters by having counter results. | 121 # Reset the counters by having counter results. |
| 108 step_status = BuildStepStatusMock(TEST_STATUS_TEXT_COUNTER) | 122 step_status = BuildStepStatusMock(TEST_STATUS_TEXT_COUNTER) |
| 109 self.assertFalse(self.notifier.isInterestingStep( | 123 self.assertFalse(self.notifier.isInterestingStep( |
| 110 build_status, step_status, results)) | 124 build_status, step_status, results)) |
| 111 # Now check that we need to count back from the start. | 125 # Now check that we need to count back from the start. |
| 112 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 126 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 113 for _ in range(self.notifier.minimum_count - 1): | 127 for _ in range(self.notifier.minimum_count - 1): |
| 114 self.assertFalse(self.notifier.isInterestingStep( | 128 self.assertFalse(self.notifier.isInterestingStep( |
| 115 build_status, step_status, results)) | 129 build_status, step_status, results)) |
| 116 self.assertTrue(self.notifier.isInterestingStep( | 130 self.assertTrue(self.notifier.isInterestingStep( |
| 117 build_status, step_status, results)) | 131 build_status, step_status, results)) |
| 118 | 132 |
| 119 def testIsInterestingResetBySuccess(self): | 133 def testIsInterestingResetBySuccess(self): |
| 120 """Test step count reset after a successful pass.""" | 134 """Test step count reset after a successful pass.""" |
| 121 build_status = None | 135 build_status = getBuildStatusMock('test_build') |
| 122 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 136 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 123 results = [FAILURE] | 137 results = [FAILURE] |
| 124 for _ in range(self.notifier.minimum_count - 1): | 138 for _ in range(self.notifier.minimum_count - 1): |
| 125 self.assertFalse(self.notifier.isInterestingStep( | 139 self.assertFalse(self.notifier.isInterestingStep( |
| 126 build_status, step_status, results)) | 140 build_status, step_status, results)) |
| 127 # Reset the counters by having a success step. | 141 # Reset the counters by having a success step. |
| 128 results = [SUCCESS] | 142 results = [SUCCESS] |
| 129 self.assertFalse(self.notifier.isInterestingStep( | 143 self.assertFalse(self.notifier.isInterestingStep( |
| 130 build_status, step_status, results)) | 144 build_status, step_status, results)) |
| 131 # Now check that we need to count back from the start. | 145 # Now check that we need to count back from the start. |
| 132 results = [1] | 146 results = [1] |
| 133 for _ in range(self.notifier.minimum_count - 1): | 147 for _ in range(self.notifier.minimum_count - 1): |
| 134 self.assertFalse(self.notifier.isInterestingStep( | 148 self.assertFalse(self.notifier.isInterestingStep( |
| 135 build_status, step_status, results)) | 149 build_status, step_status, results)) |
| 136 self.assertTrue(self.notifier.isInterestingStep( | 150 self.assertTrue(self.notifier.isInterestingStep( |
| 137 build_status, step_status, results)) | 151 build_status, step_status, results)) |
| 138 | 152 |
| 139 def testIsInterestingException(self): | 153 def testIsInterestingException(self): |
| 140 """Test step is interesting when step has exception.""" | 154 """Test step is interesting when step has exception.""" |
| 141 build_status = None | 155 build_status = getBuildStatusMock('test_build') |
| 142 step_status = BuildStepStatusMock(TEST_STATUS_TEXT_EXCEPTION) | 156 step_status = BuildStepStatusMock(TEST_STATUS_TEXT_EXCEPTION) |
| 143 results = [FAILURE] | 157 results = [FAILURE] |
| 144 self.assertTrue(self.notifier.isInterestingStep( | 158 self.assertTrue(self.notifier.isInterestingStep( |
| 145 build_status, step_status, results)) | 159 build_status, step_status, results)) |
| 146 | 160 |
| 147 def testNotificationOnce(self): | 161 def testNotificationOnce(self): |
| 148 """Test isInsteresting happens only once.""" | 162 """Test isInsteresting happens only once.""" |
| 149 build_status = None | 163 build_status = getBuildStatusMock('test_build') |
| 150 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 164 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 151 results = [FAILURE] | 165 results = [FAILURE] |
| 152 for _ in range(self.notifier.minimum_count - 1): | 166 for _ in range(self.notifier.minimum_count - 1): |
| 153 self.assertFalse(self.notifier.isInterestingStep( | 167 self.assertFalse(self.notifier.isInterestingStep( |
| 154 build_status, step_status, results)) | 168 build_status, step_status, results)) |
| 155 self.assertTrue(self.notifier.isInterestingStep( | 169 self.assertTrue(self.notifier.isInterestingStep( |
| 156 build_status, step_status, results)) | 170 build_status, step_status, results)) |
| 157 self.assertFalse(self.notifier.isInterestingStep( | 171 self.assertFalse(self.notifier.isInterestingStep( |
| 158 build_status, step_status, results)) | 172 build_status, step_status, results)) |
| 159 # Force expiration of notifications | 173 # Force expiration of notifications |
| 160 self.notifier.notifications.expiration_time = -1 | 174 self.notifier.notifications.expiration_time = -1 |
| 161 self.assertTrue(self.notifier.isInterestingStep( | 175 self.assertTrue(self.notifier.isInterestingStep( |
| 162 build_status, step_status, results)) | 176 build_status, step_status, results)) |
| 163 | 177 |
| 164 def testIsInterestingResetByOtherResults(self): | 178 def testIsInterestingResetByOtherResults(self): |
| 165 """Test isInsteresting resets after different results appear.""" | 179 """Test isInsteresting resets after different results appear.""" |
| 166 build_status = None | 180 build_status = getBuildStatusMock('test_build') |
| 167 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 181 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 168 results = [FAILURE] | 182 results = [FAILURE] |
| 169 for _ in range(self.notifier.minimum_count - 1): | 183 for _ in range(self.notifier.minimum_count - 1): |
| 170 self.assertFalse(self.notifier.isInterestingStep( | 184 self.assertFalse(self.notifier.isInterestingStep( |
| 171 build_status, step_status, results)) | 185 build_status, step_status, results)) |
| 172 # Reset the counters by having other results. | 186 # Reset the counters by having other results. |
| 173 step_status = BuildStepStatusMock(TEST_STATUS_TEXT_2) | 187 step_status = BuildStepStatusMock(TEST_STATUS_TEXT_2) |
| 174 self.assertFalse(self.notifier.isInterestingStep( | 188 self.assertFalse(self.notifier.isInterestingStep( |
| 175 build_status, step_status, results)) | 189 build_status, step_status, results)) |
| 176 # Now check that we need to count back from the start. | 190 # Now check that we need to count back from the start. |
| 177 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) | 191 step_status = BuildStepStatusMock(TEST_STATUS_TEXT) |
| 178 for _ in range(self.notifier.minimum_count - 1): | 192 for _ in range(self.notifier.minimum_count - 1): |
| 179 self.assertFalse(self.notifier.isInterestingStep( | 193 self.assertFalse(self.notifier.isInterestingStep( |
| 180 build_status, step_status, results)) | 194 build_status, step_status, results)) |
| 181 self.assertTrue(self.notifier.isInterestingStep( | 195 self.assertTrue(self.notifier.isInterestingStep( |
| 182 build_status, step_status, results)) | 196 build_status, step_status, results)) |
| 183 | 197 |
| 184 def testCountIsCorrectMultipleRegressOnly(self): | 198 def testCountIsCorrectMultipleRegressOnly(self): |
| 185 """Test count of multiple REGRESS only is correct.""" | 199 """Test count of multiple REGRESS only is correct.""" |
| 186 build_status = None | 200 build_status = getBuildStatusMock('test_build') |
| 187 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_REGRESS) | 201 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_REGRESS) |
| 188 results = [FAILURE] | 202 results = [FAILURE] |
| 189 for _ in range(self.notifier.minimum_count): | 203 for _ in range(self.notifier.minimum_count): |
| 190 self.notifier.isInterestingStep(build_status, step_status, results) | 204 self.notifier.isInterestingStep(build_status, step_status, results) |
| 191 | 205 |
| 192 self.assertEqual(self.notifier.recent_results.GetCount('REGRESS time/t'), | 206 self.assertEqual(self.getResultCount('REGRESS time/t test_build'), |
| 193 self.notifier.minimum_count) | 207 self.notifier.minimum_count) |
| 194 self.assertEqual(self.notifier.recent_results.GetCount('REGRESS fps/video'), | 208 self.assertEqual(self.getResultCount('REGRESS fps/video test_build'), |
| 195 self.notifier.minimum_count) | 209 self.notifier.minimum_count) |
| 196 self.assertEqual( | 210 self.assertEqual( |
| 197 self.notifier.recent_results.GetCount('REGRESS fps/video2'), | 211 self.getResultCount('REGRESS fps/video2 test_build'), |
| 198 self.notifier.minimum_count) | 212 self.notifier.minimum_count) |
| 199 | 213 |
| 200 def testCountIsCorrectMultipleImproveOnly(self): | 214 def testCountIsCorrectMultipleImproveOnly(self): |
| 201 """Test count of multiple IMPROVE only is correct.""" | 215 """Test count of multiple IMPROVE only is correct.""" |
| 202 build_status = None | 216 build_status = getBuildStatusMock('test_build') |
| 203 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_IMPROVE) | 217 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_IMPROVE) |
| 204 results = [FAILURE] | 218 results = [FAILURE] |
| 205 for _ in range(self.notifier.minimum_count): | 219 for _ in range(self.notifier.minimum_count): |
| 206 self.notifier.isInterestingStep(build_status, step_status, results) | 220 self.notifier.isInterestingStep(build_status, step_status, results) |
| 207 | 221 |
| 208 self.assertEqual(self.notifier.recent_results.GetCount('IMPROVE time/t'), | 222 self.assertEqual(self.getResultCount('IMPROVE time/t test_build'), |
| 209 self.notifier.minimum_count) | 223 self.notifier.minimum_count) |
| 210 self.assertEqual(self.notifier.recent_results.GetCount('IMPROVE fps/video'), | 224 self.assertEqual(self.getResultCount('IMPROVE fps/video test_build'), |
| 211 self.notifier.minimum_count) | 225 self.notifier.minimum_count) |
| 212 self.assertEqual( | 226 self.assertEqual( |
| 213 self.notifier.recent_results.GetCount('IMPROVE fps/video2'), | 227 self.getResultCount('IMPROVE fps/video2 test_build'), |
| 214 self.notifier.minimum_count) | 228 self.notifier.minimum_count) |
| 215 | 229 |
| 216 def testCountIsCorrectMultipleRegressImprove(self): | 230 def testCountIsCorrectMultipleRegressImprove(self): |
| 217 """Test count of multiple REGRESS and IMPROVE is correct.""" | 231 """Test count of multiple REGRESS and IMPROVE is correct.""" |
| 218 build_status = None | 232 build_status = getBuildStatusMock('test_build') |
| 219 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_REGRESS_IMPROVE) | 233 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_REGRESS_IMPROVE) |
| 220 results = [FAILURE] | 234 results = [FAILURE] |
| 221 for _ in range(self.notifier.minimum_count): | 235 for _ in range(self.notifier.minimum_count): |
| 222 self.notifier.isInterestingStep(build_status, step_status, results) | 236 self.notifier.isInterestingStep(build_status, step_status, results) |
| 223 | 237 |
| 224 self.assertEqual(self.notifier.recent_results.GetCount('REGRESS time/t'), | 238 self.assertEqual(self.getResultCount('REGRESS time/t test_build'), |
| 225 self.notifier.minimum_count) | 239 self.notifier.minimum_count) |
| 226 self.assertEqual(self.notifier.recent_results.GetCount('REGRESS fps/video'), | 240 self.assertEqual(self.getResultCount('REGRESS fps/video test_build'), |
| 227 self.notifier.minimum_count) | 241 self.notifier.minimum_count) |
| 228 self.assertEqual( | 242 self.assertEqual( |
| 229 self.notifier.recent_results.GetCount('REGRESS fps/video2'), | 243 self.getResultCount('REGRESS fps/video2 test_build'), |
| 230 self.notifier.minimum_count) | 244 self.notifier.minimum_count) |
| 231 | 245 |
| 232 self.assertEqual(self.notifier.recent_results.GetCount('IMPROVE cpu/t'), | 246 self.assertEqual(self.getResultCount('IMPROVE cpu/t test_build'), |
| 233 self.notifier.minimum_count) | 247 self.notifier.minimum_count) |
| 234 self.assertEqual(self.notifier.recent_results.GetCount('IMPROVE cpu/t2'), | 248 self.assertEqual(self.getResultCount('IMPROVE cpu/t2 test_build'), |
| 235 self.notifier.minimum_count) | 249 self.notifier.minimum_count) |
| 236 | 250 |
| 237 def testEmailContext(self): | 251 def testEmailContext(self): |
| 238 """Tests email context contains relative failures.""" | 252 """Tests email context contains relative failures.""" |
| 239 # Needed so that callback details are retained after method call. | 253 # Needed so that callback details are retained after method call. |
| 240 twisted.internet.defer.Deferred._startRunCallbacks = mock.Mock() | 254 twisted.internet.defer.Deferred._startRunCallbacks = mock.Mock() |
| 241 self.notifier.minimum_delay_between_alert = 0 | 255 self.notifier.minimum_delay_between_alert = 0 |
| 242 | 256 |
| 243 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_REGRESS) | 257 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_REGRESS) |
| 244 build_status = mock.Mock() | 258 build_status = getBuildStatusMock('test_build') |
| 245 build_status.getSourceStamp.return_value = None | |
| 246 build_status.getResponsibleUsers.return_value = '' | |
| 247 build_status.getChanges.return_value = '' | |
| 248 | 259 |
| 249 self.notifier.master_status = mock.Mock() | 260 self.notifier.master_status = mock.Mock() |
| 250 self.notifier.master_status.getBuildbotURL.return_value = '' | 261 self.notifier.master_status.getBuildbotURL.return_value = '' |
| 251 | 262 |
| 252 build_utils.EmailableBuildTable = mock.Mock(return_value='') | 263 build_utils.EmailableBuildTable = mock.Mock(return_value='') |
| 253 | 264 |
| 254 results = [FAILURE] | 265 results = [FAILURE] |
| 255 for _ in range(self.notifier.minimum_count): | 266 for _ in range(self.notifier.minimum_count): |
| 256 self.notifier.isInterestingStep(build_status, step_status, results) | 267 self.notifier.isInterestingStep(build_status, step_status, results) |
| 257 email = self.notifier.buildMessage(builder_name='', | 268 email = self.notifier.buildMessage(builder_name='', |
| (...skipping 18 matching lines...) Expand all Loading... |
| 276 first_callback = email.callbacks[0] | 287 first_callback = email.callbacks[0] |
| 277 callback_args = first_callback[0][1] # Defer.addCallBacks implementation | 288 callback_args = first_callback[0][1] # Defer.addCallBacks implementation |
| 278 email_content = callback_args[1].as_string() # [0] is receipients | 289 email_content = callback_args[1].as_string() # [0] is receipients |
| 279 | 290 |
| 280 self.assertTrue('New perf results in this email' in email_content) | 291 self.assertTrue('New perf results in this email' in email_content) |
| 281 self.assertTrue('PERF_REGRESS: time/t, fps/video, fps/video2.' not in | 292 self.assertTrue('PERF_REGRESS: time/t, fps/video, fps/video2.' not in |
| 282 email_content) | 293 email_content) |
| 283 self.assertTrue('PERF_REGRESS: time/t2.' in email_content) | 294 self.assertTrue('PERF_REGRESS: time/t2.' in email_content) |
| 284 self.assertTrue('PERF_IMPROVE: fps/video2.' in email_content) | 295 self.assertTrue('PERF_IMPROVE: fps/video2.' in email_content) |
| 285 | 296 |
| 297 def testResultsForDifferentBuilders(self): |
| 298 """Tests that results are unique per builder.""" |
| 299 build_linux = getBuildStatusMock('test_linux') |
| 300 build_win = getBuildStatusMock('test_win') |
| 301 step_status = BuildStepStatusMock(TEST_STATUS_MULTI_IMPROVE) |
| 302 results = [FAILURE] |
| 303 for _ in range(self.notifier.minimum_count): |
| 304 self.notifier.isInterestingStep(build_linux, step_status, results) |
| 305 self.notifier.isInterestingStep(build_win, step_status, results) |
| 306 |
| 307 # Check results store the builder names |
| 308 self.assertEqual(self.getResultCount('IMPROVE time/t test_linux'), |
| 309 self.notifier.minimum_count) |
| 310 self.assertEqual(self.getResultCount('IMPROVE time/t test_win'), |
| 311 self.notifier.minimum_count) |
| 312 |
| 313 # Reset only build_linux results |
| 314 results = [SUCCESS] |
| 315 self.assertFalse(self.notifier.isInterestingStep( |
| 316 build_linux, step_status, results)) |
| 317 |
| 318 # Check build_win results are intact. |
| 319 self.assertEqual(self.getResultCount('IMPROVE time/t test_linux'), 0) |
| 320 self.assertEqual(self.getResultCount('IMPROVE time/t test_win'), |
| 321 self.notifier.minimum_count) |
| 322 |
| 323 results = [FAILURE] |
| 324 # Add build_lin results |
| 325 for _ in range(self.notifier.minimum_count): |
| 326 self.notifier.isInterestingStep(build_linux, step_status, results) |
| 327 |
| 328 # Check results store the builder names |
| 329 self.assertEqual(self.getResultCount('IMPROVE time/t test_linux'), |
| 330 self.notifier.minimum_count) |
| 331 self.assertEqual(self.getResultCount('IMPROVE time/t test_win'), |
| 332 self.notifier.minimum_count) |
| 333 |
| 334 # Reset only build_win results |
| 335 results = [SUCCESS] |
| 336 self.assertFalse(self.notifier.isInterestingStep( |
| 337 build_win, step_status, results)) |
| 338 |
| 339 # Check build_lin results are intact. |
| 340 self.assertEqual(self.getResultCount('IMPROVE time/t test_win'), 0) |
| 341 self.assertEqual(self.getResultCount('IMPROVE time/t test_linux'), |
| 342 self.notifier.minimum_count) |
| 343 |
| 286 | 344 |
| 287 class BuildStepStatusMock(mock.Mock): | 345 class BuildStepStatusMock(mock.Mock): |
| 288 def __init__(self, text): | 346 def __init__(self, text): |
| 289 self.text = text | 347 self.text = text |
| 290 mock.Mock.__init__(self) | 348 mock.Mock.__init__(self) |
| 291 | 349 |
| 292 def getText(self): | 350 def getText(self): |
| 293 return [self.text] | 351 return [self.text] |
| 294 | 352 |
| 295 | 353 |
| 296 if __name__ == '__main__': | 354 if __name__ == '__main__': |
| 297 unittest.main() | 355 unittest.main() |
| OLD | NEW |