summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqyearsley <qyearsley@chromium.org>2015-01-28 18:36:40 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-29 02:37:43 +0000
commite9c4d717e1147c6e7248bc071450e62ea24530f1 (patch)
treee72622b536992d13070a40f1e2e14e9b630be9b3
parentd5eac382304b9d274bbb2c892cf02a0d3cb7b624 (diff)
downloadchromium_src-e9c4d717e1147c6e7248bc071450e62ea24530f1.zip
chromium_src-e9c4d717e1147c6e7248bc071450e62ea24530f1.tar.gz
chromium_src-e9c4d717e1147c6e7248bc071450e62ea24530f1.tar.bz2
Run "git stash" and "git stash apply" before and after a dry test run.
Reason: We don't want to destroy local uncommited changes when running tests. One solution was to mock bisect_utils.GitRun -- doing that caused the course of the run to change, making it so that there were no results (since git log is used to get a list of revisions, even for the dry run). So if we want to solve this problem by mocking git, we should replace it with a fake RunGit that returns different canned values depending on what the input is. The advantage of stash/apply is that its simpler, but it's also a little bit slower than the above way. BUG= Review URL: https://codereview.chromium.org/847393004 Cr-Commit-Position: refs/heads/master@{#313650}
-rw-r--r--tools/auto_bisect/bisect_perf_regression_test.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/auto_bisect/bisect_perf_regression_test.py b/tools/auto_bisect/bisect_perf_regression_test.py
index b8bd98c..f45516a 100644
--- a/tools/auto_bisect/bisect_perf_regression_test.py
+++ b/tools/auto_bisect/bisect_perf_regression_test.py
@@ -152,10 +152,12 @@ def _GenericDryRun(options, print_results=False):
Returns:
The results dictionary as returned by the bisect Run method.
"""
+ _AbortIfThereAreStagedChanges()
# Disable rmtree to avoid deleting local trees.
old_rmtree = shutil.rmtree
+ shutil.rmtree = lambda path, on_error: None
+ # git reset HEAD may be run during the dry run, which removes staged changes.
try:
- shutil.rmtree = lambda path, onerror: None
bisect_instance = _GetBisectPerformanceMetricsInstance(options)
results = bisect_instance.Run(
bisect_instance.opts.command, bisect_instance.opts.bad_revision,
@@ -169,6 +171,21 @@ def _GenericDryRun(options, print_results=False):
shutil.rmtree = old_rmtree
+def _AbortIfThereAreStagedChanges():
+ """Exits the test prematurely if there are staged changes."""
+ # The output of "git status --short" will be an empty string if there are
+ # no staged changes in the current branch. Untracked files are ignored
+ # because when running the presubmit on the trybot there are sometimes
+ # untracked changes to the run-perf-test.cfg and bisect.cfg files.
+ status_output = bisect_utils.CheckRunGit(
+ ['status', '--short', '--untracked-files=no'])
+ if status_output:
+ print 'There are un-committed changes in the current branch.'
+ print 'Aborting the tests to avoid destroying local changes. Changes:'
+ print status_output
+ sys.exit(1)
+
+
class BisectPerfRegressionTest(unittest.TestCase):
"""Test case for other functions and classes in bisect-perf-regression.py."""