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

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

Issue 584853002: Do not actually remove trees when test bisect in dry-run mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bisect-move
Patch Set: Created 6 years, 3 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 # 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 unittest 8 import unittest
8 9
9 import bisect_perf_regression 10 import bisect_perf_regression
10 import source_control as source_control_module 11 import source_control as source_control_module
11 12
12 13
13 def _GetBisectPerformanceMetricsInstance(): 14 def _GetBisectPerformanceMetricsInstance():
14 """Returns an instance of the BisectPerformanceMetrics class.""" 15 """Returns an instance of the BisectPerformanceMetrics class."""
15 options_dict = { 16 options_dict = {
16 'debug_ignore_build': True, 17 'debug_ignore_build': True,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 276628, 'chromium') 240 276628, 'chromium')
240 241
241 # 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.
242 # pylint: disable=R0201 243 # pylint: disable=R0201
243 def testDryRun(self): 244 def testDryRun(self):
244 """Does a dry run of the bisect script. 245 """Does a dry run of the bisect script.
245 246
246 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
247 script. 248 script.
248 """ 249 """
250 # Disable rmtree to avoid deleting local trees.
251 old_rmtree = shutil.rmtree
252 shutil.rmtree = lambda path, onerror: None
ojan 2014/09/19 17:42:52 I typically do this in a try/finally so you can be
Sergiy Byelozyorov 2014/09/22 20:04:15 Done.
249 bisect_instance = _GetBisectPerformanceMetricsInstance() 253 bisect_instance = _GetBisectPerformanceMetricsInstance()
250 results = bisect_instance.Run(bisect_instance.opts.command, 254 results = bisect_instance.Run(bisect_instance.opts.command,
251 bisect_instance.opts.bad_revision, 255 bisect_instance.opts.bad_revision,
252 bisect_instance.opts.good_revision, 256 bisect_instance.opts.good_revision,
253 bisect_instance.opts.metric) 257 bisect_instance.opts.metric)
254 bisect_instance.FormatAndPrintResults(results) 258 bisect_instance.FormatAndPrintResults(results)
259 shutil.rmtree = old_rmtree
255 260
256 def testGetCommitPosition(self): 261 def testGetCommitPosition(self):
257 bisect_instance = _GetBisectPerformanceMetricsInstance() 262 bisect_instance = _GetBisectPerformanceMetricsInstance()
258 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' 263 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531'
259 self.assertEqual( 264 self.assertEqual(
260 291765, bisect_instance.source_control.GetCommitPosition(cp_git_rev)) 265 291765, bisect_instance.source_control.GetCommitPosition(cp_git_rev))
261 266
262 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' 267 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58'
263 self.assertEqual( 268 self.assertEqual(
264 291467, bisect_instance.source_control.GetCommitPosition(svn_git_rev)) 269 291467, bisect_instance.source_control.GetCommitPosition(svn_git_rev))
(...skipping 29 matching lines...) Expand all
294 git_revision = 'a12345789a23456789a123456789a123456789' 299 git_revision = 'a12345789a23456789a123456789a123456789'
295 updated_content = bisect_instance.UpdateDepsContents( 300 updated_content = bisect_instance.UpdateDepsContents(
296 deps_contents, depot, git_revision, deps_key) 301 deps_contents, depot, git_revision, deps_key)
297 self.assertIsNotNone(updated_content) 302 self.assertIsNotNone(updated_content)
298 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision)) 303 ss = re.compile('["\']%s["\']: ["\']%s["\']' % (deps_key, git_revision))
299 self.assertIsNotNone(re.search(ss, updated_content)) 304 self.assertIsNotNone(re.search(ss, updated_content))
300 305
301 306
302 if __name__ == '__main__': 307 if __name__ == '__main__':
303 unittest.main() 308 unittest.main()
OLDNEW
« tools/auto_bisect/bisect_perf_regression.py ('K') | « tools/auto_bisect/bisect_perf_regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698