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

Side by Side Diff: chrome/browser/resources/PRESUBMIT.py

Issue 2684673002: MD WebUI: run vulcanize tests on PRESUBMIT (Closed)
Patch Set: -prints Created 3 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 """Presubmit script for files in chrome/browser/resources. 5 """Presubmit script for files in chrome/browser/resources.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name) 85 html_element_re = r'<(.*?)(^|\s+)metric\s*=\s*"%s"(.*?)>' % (metric_name)
86 type_re = (r'datatype\s*=\s*"boolean"|type\s*=\s*"checkbox"|' 86 type_re = (r'datatype\s*=\s*"boolean"|type\s*=\s*"checkbox"|'
87 'type\s*=\s*"radio".*?value\s*=\s*("true"|"false")') 87 'type\s*=\s*"radio".*?value\s*=\s*("true"|"false")')
88 88
89 match = input_api.re.search(html_element_re, new_content, input_api.re.DOTALL) 89 match = input_api.re.search(html_element_re, new_content, input_api.re.DOTALL)
90 return (match and 90 return (match and
91 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3))) 91 any(input_api.re.search(type_re, match.group(i)) for i in (1, 3)))
92 92
93 93
94 def RunVulcanizeTests(input_api, output_api):
95 presubmit_path = input_api.PresubmitLocalPath()
96 tests = [input_api.os_path.join(presubmit_path, 'vulcanize_gn_test.py')]
97 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests)
98
99
100 def _CheckChangeOnUploadOrCommit(input_api, output_api):
101 results = CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH)
102 affected = input_api.AffectedFiles()
103 if any(f for f in affected if f.LocalPath().endswith('vulcanize_gn.py')):
104 results += RunVulcanizeTests(input_api, output_api)
105 return results
106
107
94 def CheckChangeOnUpload(input_api, output_api): 108 def CheckChangeOnUpload(input_api, output_api):
95 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) 109 return _CheckChangeOnUploadOrCommit(input_api, output_api)
96 110
97 111
98 def CheckChangeOnCommit(input_api, output_api): 112 def CheckChangeOnCommit(input_api, output_api):
99 return CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) 113 return _CheckChangeOnUploadOrCommit(input_api, output_api)
100 114
101 115
102 def PostUploadHook(cl, change, output_api): 116 def PostUploadHook(cl, change, output_api):
103 rietveld_obj = cl.RpcServer() 117 rietveld_obj = cl.RpcServer()
104 description = rietveld_obj.get_description(cl.issue) 118 description = rietveld_obj.get_description(cl.issue)
105 119
106 existing_bots = (change.CQ_INCLUDE_TRYBOTS or '').split(';') 120 existing_bots = (change.CQ_INCLUDE_TRYBOTS or '').split(';')
107 clean_bots = set(filter(None, map(lambda s: s.strip(), existing_bots))) 121 clean_bots = set(filter(None, map(lambda s: s.strip(), existing_bots)))
108 new_bots = clean_bots | set( 122 new_bots = clean_bots | set(
109 ['master.tryserver.chromium.linux:closure_compilation']) 123 ['master.tryserver.chromium.linux:closure_compilation'])
110 new_tag = 'CQ_INCLUDE_TRYBOTS=%s' % ';'.join(new_bots) 124 new_tag = 'CQ_INCLUDE_TRYBOTS=%s' % ';'.join(new_bots)
111 125
112 if clean_bots: 126 if clean_bots:
113 tag_reg = '^CQ_INCLUDE_TRYBOTS=.*$' 127 tag_reg = '^CQ_INCLUDE_TRYBOTS=.*$'
114 new_description = re.sub(tag_reg, new_tag, description, flags=re.M | re.I) 128 new_description = re.sub(tag_reg, new_tag, description, flags=re.M | re.I)
115 else: 129 else:
116 new_description = description + '\n' + new_tag 130 new_description = description + '\n' + new_tag
117 131
118 if new_description == description: 132 if new_description == description:
119 return [] 133 return []
120 134
121 rietveld_obj.update_description(cl.issue, new_description) 135 rietveld_obj.update_description(cl.issue, new_description)
122 return [output_api.PresubmitNotifyResult( 136 return [output_api.PresubmitNotifyResult(
123 'Automatically added optional Closure bots to run on CQ.')] 137 'Automatically added optional Closure bots to run on CQ.')]
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