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

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: Removing unnecessary mocks. 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bisector = auto_bisect.bisector.Bisector(self.dummy_api, self.bisect_config, 141 bisector = auto_bisect.bisector.Bisector(self.dummy_api, self.bisect_config,
141 MockRevisionClass) 142 MockRevisionClass)
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 def test_check_initial_confidence_return_code_pass(self):
151 mock.MagicMock())
152 def test_check_initial_confidence_not_required(self):
153 return_code_config = self.bisect_config 152 return_code_config = self.bisect_config
154 return_code_config['test_type'] = 'return_code' 153 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, 154 bisector = auto_bisect.bisector.Bisector(self.dummy_api, return_code_config,
157 MockRevisionClass) 155 MockRevisionClass)
156 bisector.good_rev.overall_return_code = 0
157 bisector.bad_rev.overall_return_code = 1
158 self.assertTrue(bisector.check_initial_confidence()) 158 self.assertTrue(bisector.check_initial_confidence())
159 self.assertFalse(bisector.significantly_different.called) 159
160 def test_check_initial_confidence_return_code_fail(self):
161 return_code_config = self.bisect_config
162 return_code_config['test_type'] = 'return_code'
163 bisector = auto_bisect.bisector.Bisector(self.dummy_api, return_code_config,
164 MockRevisionClass)
165 bisector.good_rev.overall_return_code = 0
166 bisector.bad_rev.overall_return_code = 0
167 self.assertFalse(bisector.check_initial_confidence())
168
169 bisector.good_rev.overall_return_code = 1
170 bisector.bad_rev.overall_return_code = 1
171 self.assertFalse(bisector.check_initial_confidence())
160 172
161 173
162 if __name__ == '__main__': 174 if __name__ == '__main__':
163 unittest.main() # pragma: no cover 175 unittest.main() # pragma: no cover
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/auto_bisect/bisector.py ('k') | scripts/slave/recipe_modules/auto_bisect/revision_state.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698