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

Unified Diff: tools/bisect-perf-regression.py

Issue 256593004: [bisect] - Parse DEPS file manually if execfile fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 6 years, 8 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 | tools/bisect-perf-regression_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bisect-perf-regression.py
diff --git a/tools/bisect-perf-regression.py b/tools/bisect-perf-regression.py
index 6b98b4b40dcb34b7b2a7ce3f2b3f10b58fad4743..7daf0e0c3ba028bf008812ff76a4a1454e6d7062 100755
--- a/tools/bisect-perf-regression.py
+++ b/tools/bisect-perf-regression.py
@@ -76,7 +76,7 @@ DEPOT_DEPS_NAME = {
"depends" : None,
"from" : ['cros', 'android-chrome'],
'viewvc': 'http://src.chromium.org/viewvc/chrome?view=revision&revision=',
- 'deps_var': None
+ 'deps_var': 'chromium_rev'
},
'webkit' : {
"src" : "src/third_party/WebKit",
@@ -688,13 +688,19 @@ def BuildWithVisualStudio(targets):
def WriteStringToFile(text, file_name):
- with open(file_name, "w") as f:
- f.write(text)
+ try:
+ with open(file_name, "w") as f:
+ f.write(text)
+ except IOError as e:
+ raise RuntimeError('Error writing to file [%s]' % file_name )
def ReadStringFromFile(file_name):
- with open(file_name) as f:
- return f.read()
+ try:
+ with open(file_name) as f:
+ return f.read()
+ except IOError as e:
+ raise RuntimeError('Error reading file [%s]' % file_name )
def ChangeBackslashToSlashInPatch(diff_text):
@@ -740,8 +746,6 @@ class Builder(object):
if not bisect_utils.SetupPlatformBuildEnvironment(opts):
raise RuntimeError('Failed to set platform environment.')
- bisect_utils.RunGClient(['runhooks'])
-
@staticmethod
def FromOpts(opts):
builder = None
@@ -1367,23 +1371,47 @@ class BisectPerformanceMetrics(object):
return bleeding_edge_revision
- def Get3rdPartyRevisionsFromCurrentRevision(self, depot, revision):
- """Parses the DEPS file to determine WebKit/v8/etc... versions.
+ def _ParseRevisionsFromDEPSFileManually(self, deps_file_contents):
+ """Manually parses the vars section of the DEPS file to determine
+ chromium/blink/etc... revisions.
Returns:
A dict in the format {depot:revision} if successful, otherwise None.
"""
- cwd = os.getcwd()
- self.ChangeToDepotWorkingDirectory(depot)
+ # We'll parse the "vars" section of the DEPS file.
+ rxp = re.compile('vars = {(?P<vars_body>[^}]+)', re.MULTILINE)
+ re_results = rxp.search(deps_file_contents)
+ locals = {}
- results = {}
+ if not re_results:
+ return None
- if depot == 'chromium' or depot == 'android-chrome':
+ # We should be left with a series of entries in the vars component of
+ # the DEPS file with the following format:
+ # 'depot_name': 'revision',
+ vars_body = re_results.group('vars_body')
+ rxp = re.compile("'(?P<depot_body>[\w_-]+)':[\s]+'(?P<rev_body>[\w@]+)'",
+ re.MULTILINE)
+ re_results = rxp.findall(vars_body)
+
+ return dict(re_results)
+
+ def _ParseRevisionsFromDEPSFile(self, depot):
+ """Parses the local DEPS file to determine blink/skia/v8 revisions which may
+ be needed if the bisect recurses into those depots later.
+
+ Args:
+ depot: Depot being bisected.
+
+ Returns:
+ A dict in the format {depot:revision} if successful, otherwise None.
+ """
+ try:
locals = {'Var': lambda _: locals["vars"][_],
'From': lambda *args: None}
execfile(bisect_utils.FILE_DEPS_GIT, {}, locals)
-
- os.chdir(cwd)
+ locals = locals['deps']
+ results = {}
rxp = re.compile(".git@(?P<revision>[a-fA-F0-9]+)")
@@ -1394,28 +1422,61 @@ class BisectPerformanceMetrics(object):
if (DEPOT_DEPS_NAME[d]['recurse'] and
depot in DEPOT_DEPS_NAME[d]['from']):
- if (locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src']) or
- locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src_old'])):
- if locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src']):
- re_results = rxp.search(locals['deps'][DEPOT_DEPS_NAME[d]['src']])
+ if (locals.has_key(DEPOT_DEPS_NAME[d]['src']) or
+ locals.has_key(DEPOT_DEPS_NAME[d]['src_old'])):
+ if locals.has_key(DEPOT_DEPS_NAME[d]['src']):
+ re_results = rxp.search(locals[DEPOT_DEPS_NAME[d]['src']])
self.depot_cwd[d] = \
os.path.join(self.src_cwd, DEPOT_DEPS_NAME[d]['src'][4:])
- elif locals['deps'].has_key(DEPOT_DEPS_NAME[d]['src_old']):
+ elif (DEPOT_DEPS_NAME[d].has_key('src_old') and
+ locals.has_key(DEPOT_DEPS_NAME[d]['src_old'])):
re_results = \
- rxp.search(locals['deps'][DEPOT_DEPS_NAME[d]['src_old']])
+ rxp.search(locals[DEPOT_DEPS_NAME[d]['src_old']])
self.depot_cwd[d] = \
os.path.join(self.src_cwd, DEPOT_DEPS_NAME[d]['src_old'][4:])
if re_results:
results[d] = re_results.group('revision')
else:
- print 'Couldn\'t parse revision for %s.' % d
- print
- return None
+ warning_text = ('Couldn\'t parse revision for %s while bisecting '
+ '%s' % (d, depot))
+ if not warningText in self.warnings:
+ self.warnings.append(warningText)
else:
print 'Couldn\'t find %s while parsing .DEPS.git.' % d
print
return None
+ return results
+ except ImportError:
+ deps_file_contents = ReadStringFromFile(bisect_utils.FILE_DEPS_GIT)
+ parse_results = self._ParseRevisionsFromDEPSFileManually(
+ deps_file_contents)
+ results = {}
+ for depot_name, depot_revision in parse_results.iteritems():
+ depot_revision = depot_revision.strip('@')
+ print depot_name, depot_revision
+ for current_name, current_data in DEPOT_DEPS_NAME.iteritems():
+ if (current_data.has_key('deps_var') and
+ current_data['deps_var'] == depot_name):
+ src_name = current_name
+ results[src_name] = depot_revision
+ break
+ return results
+
+ def Get3rdPartyRevisionsFromCurrentRevision(self, depot, revision):
+ """Parses the DEPS file to determine WebKit/v8/etc... versions.
+
+ Returns:
+ A dict in the format {depot:revision} if successful, otherwise None.
+ """
+ cwd = os.getcwd()
+ self.ChangeToDepotWorkingDirectory(depot)
+
+ results = {}
+
+ if depot == 'chromium' or depot == 'android-chrome':
+ results = self._ParseRevisionsFromDEPSFile(depot)
+ os.chdir(cwd)
elif depot == 'cros':
cmd = [CROS_SDK_PATH, '--', 'portageq-%s' % self.opts.cros_board,
'best_visible', '/build/%s' % self.opts.cros_board, 'ebuild',
« no previous file with comments | « no previous file | tools/bisect-perf-regression_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698