| 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 re |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 from auto_bisect import source_control as source_control_module | 9 from auto_bisect import source_control as source_control_module |
| 10 | 10 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 This serves as a smoke test to catch errors in the basic execution of the | 248 This serves as a smoke test to catch errors in the basic execution of the |
| 249 script. | 249 script. |
| 250 """ | 250 """ |
| 251 bisect_instance = _GetBisectPerformanceMetricsInstance() | 251 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 252 results = bisect_instance.Run(bisect_instance.opts.command, | 252 results = bisect_instance.Run(bisect_instance.opts.command, |
| 253 bisect_instance.opts.bad_revision, | 253 bisect_instance.opts.bad_revision, |
| 254 bisect_instance.opts.good_revision, | 254 bisect_instance.opts.good_revision, |
| 255 bisect_instance.opts.metric) | 255 bisect_instance.opts.metric) |
| 256 bisect_instance.FormatAndPrintResults(results) | 256 bisect_instance.FormatAndPrintResults(results) |
| 257 | 257 |
| 258 def testSVNFindRev(self): | 258 def testGetCommitPosition(self): |
| 259 """Determine numerical SVN revision or Commit Position.""" | |
| 260 bisect_instance = _GetBisectPerformanceMetricsInstance() | 259 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 261 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' | 260 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' |
| 262 self.assertEqual(291765, | 261 self.assertEqual( |
| 263 bisect_instance.source_control.SVNFindRev(cp_git_rev)) | 262 291765, bisect_instance.source_control.GetCommitPosition(cp_git_rev)) |
| 264 | 263 |
| 265 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' | 264 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' |
| 266 self.assertEqual(291467, | 265 self.assertEqual( |
| 267 bisect_instance.source_control.SVNFindRev(svn_git_rev)) | 266 291467, bisect_instance.source_control.GetCommitPosition(svn_git_rev)) |
| 267 |
| 268 def testGetCommitPositionForV8(self): |
| 269 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 270 v8_rev = '21d700eedcdd6570eff22ece724b63a5eefe78cb' |
| 271 depot_path = os.path.join(bisect_instance.src_cwd, 'src', 'v8') |
| 272 self.assertEqual( |
| 273 23634, |
| 274 bisect_instance.source_control.GetCommitPosition(v8_rev, depot_path)) |
| 275 |
| 276 def testGetCommitPositionForWebKit(self): |
| 277 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 278 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' |
| 279 depot_path = os.path.join(bisect_instance.src_cwd, 'src', 'third_party', |
| 280 'WebKit') |
| 281 self.assertEqual( |
| 282 181660, |
| 283 bisect_instance.source_control.GetCommitPosition(wk_rev, depot_path)) |
| 268 | 284 |
| 269 def testUpdateDepsContent(self): | 285 def testUpdateDepsContent(self): |
| 270 bisect_instance = _GetBisectPerformanceMetricsInstance() | 286 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 271 deps_file = 'DEPS' | 287 deps_file = 'DEPS' |
| 272 # We are intentionally reading DEPS file contents instead of string literal | 288 # We are intentionally reading DEPS file contents instead of string literal |
| 273 # with few lines from DEPS because to check if the format we are expecting | 289 # with few lines from DEPS because to check if the format we are expecting |
| 274 # to search is not changed in DEPS content. | 290 # to search is not changed in DEPS content. |
| 275 # TODO (prasadv): Add a separate test to validate the DEPS contents with the | 291 # TODO (prasadv): Add a separate test to validate the DEPS contents with the |
| 276 # format that bisect script expects. | 292 # format that bisect script expects. |
| 277 deps_contents = bisect_perf_module.ReadStringFromFile(deps_file) | 293 deps_contents = bisect_perf_module.ReadStringFromFile(deps_file) |
| 278 deps_key = 'v8_revision' | 294 deps_key = 'v8_revision' |
| 279 depot = 'v8' | 295 depot = 'v8' |
| 280 git_revision = 'a12345789a23456789a123456789a123456789' | 296 git_revision = 'a12345789a23456789a123456789a123456789' |
| 281 updated_content = bisect_instance.UpdateDepsContents( | 297 updated_content = bisect_instance.UpdateDepsContents( |
| 282 deps_contents, depot, git_revision, deps_key) | 298 deps_contents, depot, git_revision, deps_key) |
| 283 self.assertIsNotNone(updated_content) | 299 self.assertIsNotNone(updated_content) |
| 284 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision)) | 300 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision)) |
| 285 self.assertIsNotNone(re.search(ss, updated_content)) | 301 self.assertIsNotNone(re.search(ss, updated_content)) |
| 286 | 302 |
| 287 | 303 |
| 288 if __name__ == '__main__': | 304 if __name__ == '__main__': |
| 289 unittest.main() | 305 unittest.main() |
| OLD | NEW |