Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import re | |
| 6 import unittest | 7 import unittest |
| 7 | 8 |
| 8 from auto_bisect import source_control as source_control_module | 9 from auto_bisect import source_control as source_control_module |
| 9 | 10 |
| 10 # Special import necessary because filename contains dash characters. | 11 # Special import necessary because filename contains dash characters. |
| 11 bisect_perf_module = __import__('bisect-perf-regression') | 12 bisect_perf_module = __import__('bisect-perf-regression') |
| 12 | 13 |
| 14 def GetBisectPerformanceMetricsInstance(): | |
| 15 """Returns an instance of BisectPerformanceMetrics class.""" | |
|
qyearsley
2014/09/04 18:42:36
Formatting nit: extra space. (And maybe it should
prasadv
2014/09/04 18:58:42
Done.
| |
| 16 options_dict = { | |
| 17 'debug_ignore_build': True, | |
| 18 'debug_ignore_sync': True, | |
| 19 'debug_ignore_perf_test': True, | |
| 20 'command': 'fake_command', | |
| 21 'metric': 'fake/metric', | |
| 22 'good_revision': 280000, | |
| 23 'bad_revision': 280005, | |
| 24 } | |
| 25 bisect_options = bisect_perf_module.BisectOptions.FromDict(options_dict) | |
| 26 source_control = source_control_module.DetermineAndCreateSourceControl( | |
| 27 bisect_options) | |
| 28 bisect_instance = bisect_perf_module.BisectPerformanceMetrics( | |
| 29 source_control, bisect_options) | |
| 30 bisect_instance.src_cwd = os.path.abspath( | |
| 31 os.path.join(os.path.dirname(__file__), os.path.pardir)) | |
| 32 return bisect_instance | |
|
qyearsley
2014/09/04 18:42:36
Formatting nit: Two blank spaces between top-level
prasadv
2014/09/04 18:58:42
Done.
| |
| 13 | 33 |
| 14 class BisectPerfRegressionTest(unittest.TestCase): | 34 class BisectPerfRegressionTest(unittest.TestCase): |
| 15 """Test case for other functions and classes in bisect-perf-regression.py.""" | 35 """Test case for other functions and classes in bisect-perf-regression.py.""" |
| 16 | 36 |
| 17 def _AssertConfidence(self, score, bad_values, good_values): | 37 def _AssertConfidence(self, score, bad_values, good_values): |
| 18 """Checks whether the given sets of values have a given confidence score. | 38 """Checks whether the given sets of values have a given confidence score. |
| 19 | 39 |
| 20 The score represents our confidence that the two sets of values wouldn't | 40 The score represents our confidence that the two sets of values wouldn't |
| 21 be as different as they are just by chance; that is, that some real change | 41 be as different as they are just by chance; that is, that some real change |
| 22 occurred between the two sets of values. | 42 occurred between the two sets of values. |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 276628, 'chromium') | 240 276628, 'chromium') |
| 221 | 241 |
| 222 # This method doesn't reference self; it fails if an error is thrown. | 242 # This method doesn't reference self; it fails if an error is thrown. |
| 223 # pylint: disable=R0201 | 243 # pylint: disable=R0201 |
| 224 def testDryRun(self): | 244 def testDryRun(self): |
| 225 """Does a dry run of the bisect script. | 245 """Does a dry run of the bisect script. |
| 226 | 246 |
| 227 This serves as a smoke test to catch errors in the basic execution of the | 247 This serves as a smoke test to catch errors in the basic execution of the |
| 228 script. | 248 script. |
| 229 """ | 249 """ |
| 230 options_dict = { | 250 bisect_instance = GetBisectPerformanceMetricsInstance() |
| 231 'debug_ignore_build': True, | 251 results = bisect_instance.Run(bisect_instance.opts.command, |
| 232 'debug_ignore_sync': True, | 252 bisect_instance.opts.bad_revision, |
| 233 'debug_ignore_perf_test': True, | 253 bisect_instance.opts.good_revision, |
| 234 'command': 'fake_command', | 254 bisect_instance.opts.metric) |
| 235 'metric': 'fake/metric', | |
| 236 'good_revision': 280000, | |
| 237 'bad_revision': 280005, | |
| 238 } | |
| 239 bisect_options = bisect_perf_module.BisectOptions.FromDict(options_dict) | |
| 240 source_control = source_control_module.DetermineAndCreateSourceControl( | |
| 241 bisect_options) | |
| 242 bisect_instance = bisect_perf_module.BisectPerformanceMetrics( | |
| 243 source_control, bisect_options) | |
| 244 bisect_instance.src_cwd = os.path.abspath( | |
| 245 os.path.join(os.path.dirname(__file__), '..')) | |
| 246 results = bisect_instance.Run(bisect_options.command, | |
| 247 bisect_options.bad_revision, | |
| 248 bisect_options.good_revision, | |
| 249 bisect_options.metric) | |
| 250 bisect_instance.FormatAndPrintResults(results) | 255 bisect_instance.FormatAndPrintResults(results) |
| 251 | 256 |
| 252 def testSVNFindRev(self): | 257 def testSVNFindRev(self): |
| 253 """Determine numerical SVN revision or Commit Position.""" | 258 """Determine numerical SVN revision or Commit Position.""" |
| 254 options_dict = { | 259 bisect_instance = GetBisectPerformanceMetricsInstance() |
| 255 'debug_ignore_build': True, | |
| 256 'debug_ignore_sync': True, | |
| 257 'debug_ignore_perf_test': True, | |
| 258 'command': 'fake_command', | |
| 259 'metric': 'fake/metric', | |
| 260 'good_revision': 280000, | |
| 261 'bad_revision': 280005, | |
| 262 } | |
| 263 bisect_options = bisect_perf_module.BisectOptions.FromDict(options_dict) | |
| 264 source_control = source_control_module.DetermineAndCreateSourceControl( | |
| 265 bisect_options) | |
| 266 | |
| 267 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' | 260 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' |
| 268 self.assertEqual(291765, source_control.SVNFindRev(cp_git_rev)) | 261 self.assertEqual(291765, |
| 262 bisect_instance.source_control.SVNFindRev(cp_git_rev)) | |
| 269 | 263 |
| 270 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' | 264 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' |
| 271 self.assertEqual(291467, source_control.SVNFindRev(svn_git_rev)) | 265 self.assertEqual(291467, |
| 266 bisect_instance.source_control.SVNFindRev(svn_git_rev)) | |
| 267 | |
| 268 def testUpdateDepsContent(self): | |
| 269 bisect_instance = GetBisectPerformanceMetricsInstance() | |
| 270 deps_file = 'DEPS' | |
| 271 # We are intentionally reading DEPS file contents instead of string literal | |
| 272 # with few lines from DEPS because to check if the format we are expecting | |
| 273 # to search is not changed in DEPS content. | |
| 274 # TODO (prasadv): Add a separate test to validate the DEPS contents with the | |
| 275 # format that bisect script expects. | |
| 276 deps_contents = bisect_perf_module.ReadStringFromFile(deps_file) | |
| 277 deps_key = 'v8_revision' | |
| 278 depot = 'v8' | |
| 279 git_revision = 'a12345789a23456789a123456789a123456789' | |
| 280 updated_content = bisect_instance.UpdateDepsContents( | |
| 281 deps_contents, depot, git_revision, deps_key) | |
| 282 self.assertIsNotNone(updated_content) | |
| 283 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision)) | |
| 284 self.assertIsNotNone(re.search(ss, updated_content)) | |
| 285 | |
| 286 | |
| 272 | 287 |
|
qyearsley
2014/09/04 18:42:36
Formatting nit: should be 2 blank lines rather tha
prasadv
2014/09/04 18:58:42
Done.
| |
| 273 if __name__ == '__main__': | 288 if __name__ == '__main__': |
| 274 unittest.main() | 289 unittest.main() |
| OLD | NEW |