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

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

Issue 1610203003: Iteratively increase sample size for good/bad classification. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Rebasing Created 4 years, 10 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 mock_score.return_value = 0 123 mock_score.return_value = 0
124 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass) 124 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass)
125 # The initial confidence check may only apply if there are some values. 125 # The initial confidence check may only apply if there are some values.
126 bisector.good_rev.values = [3, 3, 3, 3, 3, 3] 126 bisector.good_rev.values = [3, 3, 3, 3, 3, 3]
127 bisector.bad_rev.values = [3, 3, 3, 3, 3, 3] 127 bisector.bad_rev.values = [3, 3, 3, 3, 3, 3]
128 self.assertFalse(bisector.check_initial_confidence()) 128 self.assertFalse(bisector.check_initial_confidence())
129 self.assertTrue(bisector.failed_initial_confidence) 129 self.assertTrue(bisector.failed_initial_confidence)
130 130
131 def test_check_initial_confidence_one_hundred(self): 131 def test_check_initial_confidence_one_hundred(self):
132 # A confidence score of 100 should satisfy any default. 132 # A confidence score of 100 should satisfy any default.
133 mock_score = self.dummy_api.m.math_utils.confidence_score
134 mock_score.return_value = 100
135 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass) 133 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass)
134 bisector.good_rev.values = [3, 3, 3, 3, 3, 3]
135 bisector.bad_rev.values = [9, 9, 9, 9, 9, 9]
136 self.assertTrue(bisector.check_initial_confidence()) 136 self.assertTrue(bisector.check_initial_confidence())
137 self.assertFalse(bisector.failed_initial_confidence) 137 self.assertFalse(bisector.failed_initial_confidence)
138 138
139 def test_check_initial_confidence_not_required(self): 139 def test_check_initial_confidence_not_required(self):
140 # When confidence is not required, confidence_score should not be called. 140 # When confidence is not required, confidence_score should not be called.
141 mock_score = self.dummy_api.m.math_utils.confidence_score 141 mock_score = self.dummy_api.m.math_utils.confidence_score
142 self.bisect_config['required_initial_confidence'] = None 142 self.bisect_config['required_initial_confidence'] = None
143 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass) 143 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass)
144 self.assertTrue(bisector.check_initial_confidence()) 144 self.assertTrue(bisector.check_initial_confidence())
145 self.assertFalse(mock_score.called) 145 self.assertFalse(mock_score.called)
146 146
147 def test_check_initial_confidence_fail(self): 147 def test_check_initial_confidence_fail(self):
148 mock_score = self.dummy_api.m.math_utils.confidence_score 148 mock_score = self.dummy_api.m.math_utils.confidence_score
149 self.bisect_config['required_initial_confidence'] = 99 149 self.bisect_config['required_initial_confidence'] = 99
150 # A confidence score of 98.5 should not satisfy the required 99. 150 # A confidence score of 98.5 should not satisfy the required 99.
151 mock_score.return_value = 98.5 151 mock_score.return_value = 98.5
152 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass) 152 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass)
153 # The initial confidence check may only apply if there are some values. 153 # The initial confidence check may only apply if there are some values.
154 bisector.good_rev.values = [3, 3, 3, 3, 3, 3] 154 bisector.good_rev.values = [3, 3, 3, 3, 3, 3]
155 bisector.bad_rev.values = [3, 3, 3, 3, 3, 3] 155 bisector.bad_rev.values = [3, 3, 3, 3, 3, 3]
156 self.assertFalse(bisector.check_initial_confidence()) 156 self.assertFalse(bisector.check_initial_confidence())
157 self.assertTrue(bisector.failed_initial_confidence) 157 self.assertTrue(bisector.failed_initial_confidence)
158 158
159 def test_check_initial_confidence_pass(self):
160 mock_score = self.dummy_api.m.math_utils.confidence_score
161 self.bisect_config['required_initial_confidence'] = 99
162 # A confidence score of 99.5 should satisfy the required 99.
163 mock_score.return_value = 99.5
164 bisector = Bisector(self.dummy_api, self.bisect_config, MockRevisionClass)
165 # The initial confidence check may only apply if there are some values.
166 bisector.good_rev.values = [3, 3, 3, 3, 3, 3]
167 bisector.bad_rev.values = [3, 3, 3, 3, 3, 3]
168 self.assertTrue(bisector.check_initial_confidence())
169 self.assertFalse(bisector.failed_initial_confidence)
170
171 159
172 if __name__ == '__main__': 160 if __name__ == '__main__':
173 unittest.main() # pragma: no cover 161 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/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698