Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: scripts/slave/recipe_modules/auto_bisect/bisector_test.py

Issue 1825993003: Making check_initial_confidence verify return_code bisects. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Adressing feedback. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 copy 6 import copy
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
(...skipping 13 matching lines...) Expand all
24 def __init__( 24 def __init__(
25 self, bisector, commit_hash, 25 self, bisector, commit_hash,
26 depot_name='chromium', base_revision=None): 26 depot_name='chromium', base_revision=None):
27 self.bisector = bisector 27 self.bisector = bisector
28 self.commit_hash = commit_hash 28 self.commit_hash = commit_hash
29 self.depot_name = depot_name 29 self.depot_name = depot_name
30 self.base_revision = base_revision 30 self.base_revision = base_revision
31 self.previous_revision = None 31 self.previous_revision = None
32 self.next_revision = None 32 self.next_revision = None
33 self.values = [] 33 self.values = []
34 self.overall_return_code = None
34 self.deps = {} 35 self.deps = {}
35 self.status = '' 36 self.status = ''
36 37
37 def read_deps(self, tester_name): 38 def read_deps(self, tester_name):
38 pass 39 pass
39 40
40 def retest(self): 41 def retest(self):
41 self.bisector.last_tested_revision = self 42 self.bisector.last_tested_revision = self
42 self.values.append(3) 43 self.values.append(3)
43 44
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 bisector.good_rev.values = [3, 3, 3, 3, 3, 3] 143 bisector.good_rev.values = [3, 3, 3, 3, 3, 3]
143 bisector.bad_rev.values = [3, 3, 3, 3] 144 bisector.bad_rev.values = [3, 3, 3, 3]
144 self.assertFalse(bisector.check_initial_confidence()) 145 self.assertFalse(bisector.check_initial_confidence())
145 self.assertTrue(len(bisector.bad_rev.values) >= 146 self.assertTrue(len(bisector.bad_rev.values) >=
146 auto_bisect.bisector.MAX_REQUIRED_SAMPLES or 147 auto_bisect.bisector.MAX_REQUIRED_SAMPLES or
147 len(bisector.good_rev.values) >= 148 len(bisector.good_rev.values) >=
148 auto_bisect.bisector.MAX_REQUIRED_SAMPLES) 149 auto_bisect.bisector.MAX_REQUIRED_SAMPLES)
149 150
150 @mock.patch.object(auto_bisect.bisector.Bisector, 'significantly_different', 151 @mock.patch.object(auto_bisect.bisector.Bisector, 'significantly_different',
151 mock.MagicMock()) 152 mock.MagicMock())
152 def test_check_initial_confidence_not_required(self): 153 def test_check_initial_confidence_return_code_pass(self):
153 return_code_config = self.bisect_config 154 return_code_config = self.bisect_config
154 return_code_config['test_type'] = 'return_code' 155 return_code_config['test_type'] = 'return_code'
155 # When confidence is not required, confidence_score should not be called.
156 bisector = auto_bisect.bisector.Bisector(self.dummy_api, return_code_config, 156 bisector = auto_bisect.bisector.Bisector(self.dummy_api, return_code_config,
157 MockRevisionClass) 157 MockRevisionClass)
158 bisector.good_rev.overall_return_code = 0
159 bisector.bad_rev.overall_return_code = 1
158 self.assertTrue(bisector.check_initial_confidence()) 160 self.assertTrue(bisector.check_initial_confidence())
159 self.assertFalse(bisector.significantly_different.called) 161
162 @mock.patch.object(auto_bisect.bisector.Bisector, 'significantly_different',
163 mock.MagicMock())
qyearsley 2016/03/23 22:09:36 There is no longer the line self.assertFalse(bisec
164 def test_check_initial_confidence_return_code_fail(self):
165 return_code_config = self.bisect_config
166 return_code_config['test_type'] = 'return_code'
167 bisector = auto_bisect.bisector.Bisector(self.dummy_api, return_code_config,
168 MockRevisionClass)
169 bisector.good_rev.overall_return_code = 0
170 bisector.bad_rev.overall_return_code = 0
171 self.assertFalse(bisector.check_initial_confidence())
172
173 bisector.good_rev.overall_return_code = 1
174 bisector.bad_rev.overall_return_code = 1
175 self.assertFalse(bisector.check_initial_confidence())
160 176
161 177
162 if __name__ == '__main__': 178 if __name__ == '__main__':
163 unittest.main() # pragma: no cover 179 unittest.main() # pragma: no cover
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698