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

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

Issue 847393004: Run "git stash" and "git stash apply" before and after a dry test run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ignore untracked files (in the presubmit there appeared were untracked changes to the cfg files) Created 5 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
« no previous file with comments | « no previous file | no next file » | 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
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 def _GenericDryRun(options, print_results=False): 145 def _GenericDryRun(options, print_results=False):
146 """Performs a dry run of the bisector. 146 """Performs a dry run of the bisector.
147 147
148 Args: 148 Args:
149 options: Dictionary containing the options for the bisect instance. 149 options: Dictionary containing the options for the bisect instance.
150 print_results: Boolean telling whether to call FormatAndPrintResults. 150 print_results: Boolean telling whether to call FormatAndPrintResults.
151 151
152 Returns: 152 Returns:
153 The results dictionary as returned by the bisect Run method. 153 The results dictionary as returned by the bisect Run method.
154 """ 154 """
155 _AbortIfThereAreStagedChanges()
155 # Disable rmtree to avoid deleting local trees. 156 # Disable rmtree to avoid deleting local trees.
156 old_rmtree = shutil.rmtree 157 old_rmtree = shutil.rmtree
158 shutil.rmtree = lambda path, on_error: None
159 # git reset HEAD may be run during the dry run, which removes staged changes.
157 try: 160 try:
158 shutil.rmtree = lambda path, onerror: None
159 bisect_instance = _GetBisectPerformanceMetricsInstance(options) 161 bisect_instance = _GetBisectPerformanceMetricsInstance(options)
160 results = bisect_instance.Run( 162 results = bisect_instance.Run(
161 bisect_instance.opts.command, bisect_instance.opts.bad_revision, 163 bisect_instance.opts.command, bisect_instance.opts.bad_revision,
162 bisect_instance.opts.good_revision, bisect_instance.opts.metric) 164 bisect_instance.opts.good_revision, bisect_instance.opts.metric)
163 165
164 if print_results: 166 if print_results:
165 bisect_instance.printer.FormatAndPrintResults(results) 167 bisect_instance.printer.FormatAndPrintResults(results)
166 168
167 return results 169 return results
168 finally: 170 finally:
169 shutil.rmtree = old_rmtree 171 shutil.rmtree = old_rmtree
170 172
171 173
174 def _AbortIfThereAreStagedChanges():
175 """Exits the test prematurely if there are staged changes."""
176 # The output of "git status --short" will be an empty string if there are
177 # no staged changes in the current branch. Untracked files are ignored
178 # because when running the presubmit on the trybot there are sometimes
179 # untracked changes to the run-perf-test.cfg and bisect.cfg files.
180 status_output = bisect_utils.CheckRunGit(
181 ['status', '--short', '--untracked-files=no'])
182 if status_output:
183 print 'There are un-committed changes in the current branch.'
184 print 'Aborting the tests to avoid destroying local changes. Changes:'
185 print status_output
186 sys.exit(1)
187
188
172 class BisectPerfRegressionTest(unittest.TestCase): 189 class BisectPerfRegressionTest(unittest.TestCase):
173 """Test case for other functions and classes in bisect-perf-regression.py.""" 190 """Test case for other functions and classes in bisect-perf-regression.py."""
174 191
175 def setUp(self): 192 def setUp(self):
176 self.cwd = os.getcwd() 193 self.cwd = os.getcwd()
177 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), 194 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__),
178 os.path.pardir, os.path.pardir))) 195 os.path.pardir, os.path.pardir)))
179 196
180 def tearDown(self): 197 def tearDown(self):
181 os.chdir(self.cwd) 198 os.chdir(self.cwd)
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ] 659 ]
643 self._SetupRunGitMock(try_cmd) 660 self._SetupRunGitMock(try_cmd)
644 bisect_perf_regression._StartBuilderTryJob( 661 bisect_perf_regression._StartBuilderTryJob(
645 fetch_build.PERF_BUILDER, git_revision, bot_name, bisect_job_name, 662 fetch_build.PERF_BUILDER, git_revision, bot_name, bisect_job_name,
646 patch) 663 patch)
647 664
648 665
649 if __name__ == '__main__': 666 if __name__ == '__main__':
650 unittest.main() 667 unittest.main()
651 668
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698