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

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: Change to abort test if there are staged changes. Created 5 years, 11 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 def _GenericDryRun(options, print_results=False): 144 def _GenericDryRun(options, print_results=False):
145 """Performs a dry run of the bisector. 145 """Performs a dry run of the bisector.
146 146
147 Args: 147 Args:
148 options: Dictionary containing the options for the bisect instance. 148 options: Dictionary containing the options for the bisect instance.
149 print_results: Boolean telling whether to call FormatAndPrintResults. 149 print_results: Boolean telling whether to call FormatAndPrintResults.
150 150
151 Returns: 151 Returns:
152 The results dictionary as returned by the bisect Run method. 152 The results dictionary as returned by the bisect Run method.
153 """ 153 """
154 _AbortIfThereAreUncommittedChanges()
154 # Disable rmtree to avoid deleting local trees. 155 # Disable rmtree to avoid deleting local trees.
155 old_rmtree = shutil.rmtree 156 old_rmtree = shutil.rmtree
157 shutil.rmtree = lambda path, on_error: None
158 # git reset HEAD may be run during the dry run, which removes staged changes.
156 try: 159 try:
157 shutil.rmtree = lambda path, onerror: None
158 bisect_instance = _GetBisectPerformanceMetricsInstance(options) 160 bisect_instance = _GetBisectPerformanceMetricsInstance(options)
159 results = bisect_instance.Run( 161 results = bisect_instance.Run(
160 bisect_instance.opts.command, bisect_instance.opts.bad_revision, 162 bisect_instance.opts.command, bisect_instance.opts.bad_revision,
161 bisect_instance.opts.good_revision, bisect_instance.opts.metric) 163 bisect_instance.opts.good_revision, bisect_instance.opts.metric)
162 164
163 if print_results: 165 if print_results:
164 bisect_instance.printer.FormatAndPrintResults(results) 166 bisect_instance.printer.FormatAndPrintResults(results)
165 167
166 return results 168 return results
167 finally: 169 finally:
168 shutil.rmtree = old_rmtree 170 shutil.rmtree = old_rmtree
169 171
170 172
173 def _AbortIfThereAreUncommittedChanges():
174 """Exits the test prematurely if there are staged changes."""
175 changes = bisect_utils.CheckRunGit(['status', '--short'])
176 if changes.strip():
prasadv 2015/01/27 22:32:32 What does "CheckRunGit" returns when there is no c
qyearsley 2015/01/27 23:49:01 CheckRunGit returns an empty string when there are
177 print 'There are un-committed changes in the current branch.'
178 print 'Aborting the tests to avoid destroying local changes.'
179 sys.exit(1)
180
181
171 class BisectPerfRegressionTest(unittest.TestCase): 182 class BisectPerfRegressionTest(unittest.TestCase):
172 """Test case for other functions and classes in bisect-perf-regression.py.""" 183 """Test case for other functions and classes in bisect-perf-regression.py."""
173 184
174 def setUp(self): 185 def setUp(self):
175 self.cwd = os.getcwd() 186 self.cwd = os.getcwd()
176 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), 187 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__),
177 os.path.pardir, os.path.pardir))) 188 os.path.pardir, os.path.pardir)))
178 189
179 def tearDown(self): 190 def tearDown(self):
180 os.chdir(self.cwd) 191 os.chdir(self.cwd)
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 ], (None, 0)), 649 ], (None, 0)),
639 ] 650 ]
640 self._SetupRunGitMock(try_cmd) 651 self._SetupRunGitMock(try_cmd)
641 bisect_perf_regression._BuilderTryjob( 652 bisect_perf_regression._BuilderTryjob(
642 git_revision, bot_name, bisect_job_name, patch) 653 git_revision, bot_name, bisect_job_name, patch)
643 654
644 655
645 if __name__ == '__main__': 656 if __name__ == '__main__':
646 unittest.main() 657 unittest.main()
647 658
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