OLD | NEW |
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 def CheckHtml(input_api, output_api): | 94 def CheckHtml(input_api, output_api): |
95 return input_api.canned_checks.CheckLongLines( | 95 return input_api.canned_checks.CheckLongLines( |
96 input_api, output_api, 80, lambda x: x.LocalPath().endswith('.html')) | 96 input_api, output_api, 80, lambda x: x.LocalPath().endswith('.html')) |
97 | 97 |
98 | 98 |
99 def RunVulcanizeTests(input_api, output_api): | 99 def RunVulcanizeTests(input_api, output_api): |
100 presubmit_path = input_api.PresubmitLocalPath() | 100 presubmit_path = input_api.PresubmitLocalPath() |
101 tests = [input_api.os_path.join(presubmit_path, 'vulcanize_gn_test.py')] | 101 tests = [input_api.os_path.join(presubmit_path, 'vulcanize_gn_test.py')] |
102 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) | 102 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) |
103 | 103 |
| 104 def RunRewriteLicensesTests(input_api, output_api): |
| 105 presubmit_path = input_api.PresubmitLocalPath() |
| 106 tests = [input_api.os_path.join(presubmit_path, 'rewrite_licenses_test.py')] |
| 107 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) |
| 108 |
104 | 109 |
105 def _CheckChangeOnUploadOrCommit(input_api, output_api): | 110 def _CheckChangeOnUploadOrCommit(input_api, output_api): |
106 results = CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) | 111 results = CheckUserActionUpdate(input_api, output_api, ACTION_XML_PATH) |
107 affected = input_api.AffectedFiles() | 112 affected = input_api.AffectedFiles() |
108 if any(f for f in affected if f.LocalPath().endswith('.html')): | 113 if any(f for f in affected if f.LocalPath().endswith('.html')): |
109 results += CheckHtml(input_api, output_api) | 114 results += CheckHtml(input_api, output_api) |
110 if any(f for f in affected if f.LocalPath().endswith('vulcanize_gn.py')): | 115 if any(f for f in affected if f.LocalPath().endswith('vulcanize_gn.py')): |
111 results += RunVulcanizeTests(input_api, output_api) | 116 results += RunVulcanizeTests(input_api, output_api) |
| 117 if any(f for f in affected if f.LocalPath().endswith('rewrite_licenses.py')): |
| 118 results += RunRewriteLicensesTests(input_api, output_api) |
112 return results | 119 return results |
113 | 120 |
114 | 121 |
115 def CheckChangeOnUpload(input_api, output_api): | 122 def CheckChangeOnUpload(input_api, output_api): |
116 return _CheckChangeOnUploadOrCommit(input_api, output_api) | 123 return _CheckChangeOnUploadOrCommit(input_api, output_api) |
117 | 124 |
118 | 125 |
119 def CheckChangeOnCommit(input_api, output_api): | 126 def CheckChangeOnCommit(input_api, output_api): |
120 return _CheckChangeOnUploadOrCommit(input_api, output_api) | 127 return _CheckChangeOnUploadOrCommit(input_api, output_api) |
121 | 128 |
122 | 129 |
123 def PostUploadHook(cl, change, output_api): | 130 def PostUploadHook(cl, change, output_api): |
124 return output_api.EnsureCQIncludeTrybotsAreAdded( | 131 return output_api.EnsureCQIncludeTrybotsAreAdded( |
125 cl, | 132 cl, |
126 [ | 133 [ |
127 'master.tryserver.chromium.linux:closure_compilation', | 134 'master.tryserver.chromium.linux:closure_compilation', |
128 ], | 135 ], |
129 'Automatically added optional Closure bots to run on CQ.') | 136 'Automatically added optional Closure bots to run on CQ.') |
OLD | NEW |