Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 changes affecting extensions. | 5 """Presubmit script for changes affecting extensions. |
| 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 gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 import fnmatch | 10 import fnmatch |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 if (fnmatch.fnmatch(name, '%s*' % PUBLIC_TEMPLATES_PATH) or | 66 if (fnmatch.fnmatch(name, '%s*' % PUBLIC_TEMPLATES_PATH) or |
| 67 fnmatch.fnmatch(name, '%s*' % INTROS_PATH) or | 67 fnmatch.fnmatch(name, '%s*' % INTROS_PATH) or |
| 68 fnmatch.fnmatch(name, '%s*' % ARTICLES_PATH)): | 68 fnmatch.fnmatch(name, '%s*' % ARTICLES_PATH)): |
| 69 args.extend(_FindMatchingTemplates(name.split(os.sep)[-1], | 69 args.extend(_FindMatchingTemplates(name.split(os.sep)[-1], |
| 70 _ListFilesInPublic())) | 70 _ListFilesInPublic())) |
| 71 if fnmatch.fnmatch(name, '%s*' % API_PATH): | 71 if fnmatch.fnmatch(name, '%s*' % API_PATH): |
| 72 args.extend(_FindMatchingTemplates(_SanitizeAPIName(name, API_PATH), | 72 args.extend(_FindMatchingTemplates(_SanitizeAPIName(name, API_PATH), |
| 73 _ListFilesInPublic())) | 73 _ListFilesInPublic())) |
| 74 return args | 74 return args |
| 75 | 75 |
| 76 def _CheckHeadingIDs(input_api): | |
| 77 ids_re = re.compile('<h[23].*id=.*?>') | |
| 78 headings_re = re.compile('<h[23].*?>') | |
| 79 bad_files = [] | |
| 80 for name in input_api.AbsoluteLocalPaths(): | |
| 81 if (fnmatch.fnmatch(name, '*%s*' % INTROS_PATH) or | |
| 82 fnmatch.fnmatch(name, '*%s*' % ARTICLES_PATH)): | |
| 83 contents = input_api.ReadFile(name) | |
| 84 if (len(re.findall(headings_re, contents)) != | |
| 85 len(re.findall(ids_re, contents))): | |
| 86 bad_files.append(name) | |
| 87 return bad_files | |
| 88 | |
| 76 def _CheckChange(input_api, output_api): | 89 def _CheckChange(input_api, output_api): |
| 77 results = [] | 90 results = [] |
| 91 results.extend( | |
| 92 output_api.PresubmitError('File %s needs an id for each heading.' % name) | |
| 93 for name in _CheckHeadingIDs(input_api)) | |
|
not at google - send to devlin
2012/09/26 01:57:17
just assign into results straight away?
cduvall
2012/09/27 23:39:39
Done.
| |
| 78 try: | 94 try: |
| 79 integration_test = [] | 95 integration_test = [] |
| 80 # From depot_tools/presubmit_canned_checks.py:529 | 96 # From depot_tools/presubmit_canned_checks.py:529 |
| 81 if input_api.platform == 'win32': | 97 if input_api.platform == 'win32': |
| 82 integration_test = [input_api.python_executable] | 98 integration_test = [input_api.python_executable] |
| 83 integration_test.append( | 99 integration_test.append( |
| 84 os.path.join('docs', 'server2', 'integration_test.py')) | 100 os.path.join('docs', 'server2', 'integration_test.py')) |
| 85 integration_test.extend(_CreateIntegrationTestArgs(input_api.LocalPaths())) | 101 integration_test.extend(_CreateIntegrationTestArgs(input_api.LocalPaths())) |
| 86 input_api.subprocess.check_call(integration_test, | 102 input_api.subprocess.check_call(integration_test, |
| 87 cwd=input_api.PresubmitLocalPath()) | 103 cwd=input_api.PresubmitLocalPath()) |
| 88 except input_api.subprocess.CalledProcessError: | 104 except input_api.subprocess.CalledProcessError: |
| 89 results.append(output_api.PresubmitError('IntegrationTest failed!')) | 105 results.append(output_api.PresubmitError('IntegrationTest failed!')) |
| 90 return results | 106 return results |
| 91 | 107 |
| 92 def CheckChangeOnUpload(input_api, output_api): | 108 def CheckChangeOnUpload(input_api, output_api): |
| 93 return _CheckChange(input_api, output_api) | 109 return _CheckChange(input_api, output_api) |
| 94 | 110 |
| 95 def CheckChangeOnCommit(input_api, output_api): | 111 def CheckChangeOnCommit(input_api, output_api): |
| 96 return _CheckChange(input_api, output_api) | 112 return _CheckChange(input_api, output_api) |
| OLD | NEW |