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

Side by Side Diff: tools/auto_bisect/bisect_perf_regression_test.py

Issue 650223005: Refactor source_control.py and add a test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 2 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
« no previous file with comments | « tools/auto_bisect/bisect_perf_regression.py ('k') | tools/auto_bisect/bisect_results.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 shutil 7 import shutil
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) 11 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)
12 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) 12 sys.path.append(os.path.join(SRC, 'third_party', 'pymock'))
13 13
14 import bisect_perf_regression 14 import bisect_perf_regression
15 import bisect_results 15 import bisect_results
16 import mock 16 import mock
17 import source_control as source_control_module 17 import source_control
18 18
19 19
20 def _GetBisectPerformanceMetricsInstance(): 20 def _GetBisectPerformanceMetricsInstance():
21 """Returns an instance of the BisectPerformanceMetrics class.""" 21 """Returns an instance of the BisectPerformanceMetrics class."""
22 options_dict = { 22 options_dict = {
23 'debug_ignore_build': True, 23 'debug_ignore_build': True,
24 'debug_ignore_sync': True, 24 'debug_ignore_sync': True,
25 'debug_ignore_perf_test': True, 25 'debug_ignore_perf_test': True,
26 'command': 'fake_command', 26 'command': 'fake_command',
27 'metric': 'fake/metric', 27 'metric': 'fake/metric',
28 'good_revision': 280000, 28 'good_revision': 280000,
29 'bad_revision': 280005, 29 'bad_revision': 280005,
30 } 30 }
31 bisect_options = bisect_perf_regression.BisectOptions.FromDict(options_dict) 31 bisect_options = bisect_perf_regression.BisectOptions.FromDict(options_dict)
32 source_control = source_control_module.DetermineAndCreateSourceControl( 32 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics(
33 bisect_options) 33 bisect_options)
34 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics(
35 source_control, bisect_options)
36 return bisect_instance 34 return bisect_instance
37 35
38 36
39 class BisectPerfRegressionTest(unittest.TestCase): 37 class BisectPerfRegressionTest(unittest.TestCase):
40 """Test case for other functions and classes in bisect-perf-regression.py.""" 38 """Test case for other functions and classes in bisect-perf-regression.py."""
41 39
42 def setUp(self): 40 def setUp(self):
43 self.cwd = os.getcwd() 41 self.cwd = os.getcwd()
44 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), 42 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__),
45 os.path.pardir, os.path.pardir))) 43 os.path.pardir, os.path.pardir)))
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 command that works; before some revisions, the browser name that Telemetry 198 command that works; before some revisions, the browser name that Telemetry
201 expects is different in some cases, but we want it to work anyway. 199 expects is different in some cases, but we want it to work anyway.
202 200
203 Specifically, only for android: 201 Specifically, only for android:
204 After r276628, only android-chrome-shell works. 202 After r276628, only android-chrome-shell works.
205 Prior to r274857, only android-chromium-testshell works. 203 Prior to r274857, only android-chromium-testshell works.
206 In the range [274857, 276628], both work. 204 In the range [274857, 276628], both work.
207 """ 205 """
208 bisect_options = bisect_perf_regression.BisectOptions() 206 bisect_options = bisect_perf_regression.BisectOptions()
209 bisect_options.output_buildbot_annotations = None 207 bisect_options.output_buildbot_annotations = None
210 source_control = source_control_module.DetermineAndCreateSourceControl( 208 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics(
211 bisect_options) 209 bisect_options)
212 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics(
213 source_control, bisect_options)
214 bisect_instance.opts.target_platform = target_platform 210 bisect_instance.opts.target_platform = target_platform
215 git_revision = bisect_instance.source_control.ResolveToRevision( 211 git_revision = source_control.ResolveToRevision(
216 revision, 'chromium', bisect_perf_regression.DEPOT_DEPS_NAME, 100) 212 revision, 'chromium', bisect_perf_regression.DEPOT_DEPS_NAME, 100)
217 depot = 'chromium' 213 depot = 'chromium'
218 command = bisect_instance.GetCompatibleCommand( 214 command = bisect_instance.GetCompatibleCommand(
219 original_command, git_revision, depot) 215 original_command, git_revision, depot)
220 self.assertEqual(expected_command, command) 216 self.assertEqual(expected_command, command)
221 217
222 def testGetCompatibleCommand_ChangeToTestShell(self): 218 def testGetCompatibleCommand_ChangeToTestShell(self):
223 # For revisions <= r274857, only android-chromium-testshell is used. 219 # For revisions <= r274857, only android-chromium-testshell is used.
224 self._AssertCompatibleCommand( 220 self._AssertCompatibleCommand(
225 'tools/perf/run_benchmark -v --browser=android-chromium-testshell foo', 221 'tools/perf/run_benchmark -v --browser=android-chromium-testshell foo',
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 bisect_instance = _GetBisectPerformanceMetricsInstance() 264 bisect_instance = _GetBisectPerformanceMetricsInstance()
269 results = bisect_instance.Run(bisect_instance.opts.command, 265 results = bisect_instance.Run(bisect_instance.opts.command,
270 bisect_instance.opts.bad_revision, 266 bisect_instance.opts.bad_revision,
271 bisect_instance.opts.good_revision, 267 bisect_instance.opts.good_revision,
272 bisect_instance.opts.metric) 268 bisect_instance.opts.metric)
273 bisect_instance.FormatAndPrintResults(results) 269 bisect_instance.FormatAndPrintResults(results)
274 finally: 270 finally:
275 shutil.rmtree = old_rmtree 271 shutil.rmtree = old_rmtree
276 272
277 def testGetCommitPosition(self): 273 def testGetCommitPosition(self):
278 bisect_instance = _GetBisectPerformanceMetricsInstance()
279 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' 274 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531'
280 self.assertEqual( 275 self.assertEqual(291765, source_control.GetCommitPosition(cp_git_rev))
281 291765, bisect_instance.source_control.GetCommitPosition(cp_git_rev))
282 276
283 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' 277 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58'
284 self.assertEqual( 278 self.assertEqual(291467, source_control.GetCommitPosition(svn_git_rev))
285 291467, bisect_instance.source_control.GetCommitPosition(svn_git_rev))
286 279
287 def testGetCommitPositionForV8(self): 280 def testGetCommitPositionForV8(self):
288 bisect_instance = _GetBisectPerformanceMetricsInstance() 281 bisect_instance = _GetBisectPerformanceMetricsInstance()
289 v8_rev = '21d700eedcdd6570eff22ece724b63a5eefe78cb' 282 v8_rev = '21d700eedcdd6570eff22ece724b63a5eefe78cb'
290 depot_path = os.path.join(bisect_instance.src_cwd, 'v8') 283 depot_path = os.path.join(bisect_instance.src_cwd, 'v8')
291 self.assertEqual( 284 self.assertEqual(
292 23634, 285 23634, source_control.GetCommitPosition(v8_rev, depot_path))
293 bisect_instance.source_control.GetCommitPosition(v8_rev, depot_path))
294 286
295 def testGetCommitPositionForWebKit(self): 287 def testGetCommitPositionForWebKit(self):
296 bisect_instance = _GetBisectPerformanceMetricsInstance() 288 bisect_instance = _GetBisectPerformanceMetricsInstance()
297 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' 289 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61'
298 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'WebKit') 290 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'WebKit')
299 self.assertEqual( 291 self.assertEqual(
300 181660, 292 181660, source_control.GetCommitPosition(wk_rev, depot_path))
301 bisect_instance.source_control.GetCommitPosition(wk_rev, depot_path))
302 293
303 def testUpdateDepsContent(self): 294 def testUpdateDepsContent(self):
304 bisect_instance = _GetBisectPerformanceMetricsInstance() 295 bisect_instance = _GetBisectPerformanceMetricsInstance()
305 deps_file = 'DEPS' 296 deps_file = 'DEPS'
306 # We are intentionally reading DEPS file contents instead of string literal 297 # We are intentionally reading DEPS file contents instead of string literal
307 # with few lines from DEPS because to check if the format we are expecting 298 # with few lines from DEPS because to check if the format we are expecting
308 # to search is not changed in DEPS content. 299 # to search is not changed in DEPS content.
309 # TODO (prasadv): Add a separate test to validate the DEPS contents with the 300 # TODO (prasadv): Add a separate test to validate the DEPS contents with the
310 # format that bisect script expects. 301 # format that bisect script expects.
311 deps_contents = bisect_perf_regression.ReadStringFromFile(deps_file) 302 deps_contents = bisect_perf_regression.ReadStringFromFile(deps_file)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 '--diff=%s' % patch_content 491 '--diff=%s' % patch_content
501 ], (None, 0)) 492 ], (None, 0))
502 ] 493 ]
503 self._SetupRunGitMock(try_cmd) 494 self._SetupRunGitMock(try_cmd)
504 bisect_perf_regression._BuilderTryjob( 495 bisect_perf_regression._BuilderTryjob(
505 git_revision, bot_name, bisect_job_name, patch) 496 git_revision, bot_name, bisect_job_name, patch)
506 497
507 498
508 if __name__ == '__main__': 499 if __name__ == '__main__':
509 unittest.main() 500 unittest.main()
OLDNEW
« no previous file with comments | « tools/auto_bisect/bisect_perf_regression.py ('k') | tools/auto_bisect/bisect_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698