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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/auto_bisect/bisect_perf_regression_test.py
diff --git a/tools/auto_bisect/bisect_perf_regression_test.py b/tools/auto_bisect/bisect_perf_regression_test.py
index b8bd98c445086f0e62970612d8133a0cab0ea7a6..f45516a27a3ae6c7774f91f8a36d9621ba3668d2 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."""
« 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