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 Chromium browser code. | 5 """Presubmit script for Chromium browser code. |
6 | 6 |
7 This script currently only checks HTML/CSS/JS files in resources/. | 7 This script currently only checks HTML/CSS/JS files in resources/. |
8 | 8 |
9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
10 for more details about the presubmit API built into gcl/git cl, and see | 10 for more details about the presubmit API built into gcl/git cl, and see |
(...skipping 29 matching lines...) Expand all Loading... |
40 if any(f for f in affected_files if f in would_affect_tests): | 40 if any(f for f in affected_files if f in would_affect_tests): |
41 tests = [path.join(cwd, 'test_presubmit.py')] | 41 tests = [path.join(cwd, 'test_presubmit.py')] |
42 results.extend( | 42 results.extend( |
43 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) | 43 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) |
44 | 44 |
45 import sys | 45 import sys |
46 old_path = sys.path | 46 old_path = sys.path |
47 | 47 |
48 try: | 48 try: |
49 sys.path = [cwd] + old_path | 49 sys.path = [cwd] + old_path |
50 from web_dev_style import css_checker, js_checker | 50 from web_dev_style import resource_checker, css_checker, js_checker |
51 | 51 |
52 search_dirs = (resources, webui) | 52 search_dirs = (resources, webui) |
53 def _html_css_js_resource(p): | 53 def _html_css_js_resource(p): |
54 return p.endswith(('.html', '.css', '.js')) and p.startswith(search_dirs) | 54 return p.endswith(('.html', '.css', '.js')) and p.startswith(search_dirs) |
55 | 55 |
56 BLACKLIST = ['chrome/browser/resources/pdf/index.html', | 56 BLACKLIST = ['chrome/browser/resources/pdf/index.html', |
57 'chrome/browser/resources/pdf/index.js'] | 57 'chrome/browser/resources/pdf/index.js'] |
58 def is_resource(maybe_resource): | 58 def is_resource(maybe_resource): |
59 return (maybe_resource.LocalPath() not in BLACKLIST and | 59 return (maybe_resource.LocalPath() not in BLACKLIST and |
60 _html_css_js_resource(maybe_resource.AbsoluteLocalPath())) | 60 _html_css_js_resource(maybe_resource.AbsoluteLocalPath())) |
61 | 61 |
| 62 results.extend(resource_checker.ResourceChecker( |
| 63 input_api, output_api, file_filter=is_resource).RunChecks()) |
62 results.extend(css_checker.CSSChecker( | 64 results.extend(css_checker.CSSChecker( |
63 input_api, output_api, file_filter=is_resource).RunChecks()) | 65 input_api, output_api, file_filter=is_resource).RunChecks()) |
64 results.extend(js_checker.JSChecker( | 66 results.extend(js_checker.JSChecker( |
65 input_api, output_api, file_filter=is_resource).RunChecks()) | 67 input_api, output_api, file_filter=is_resource).RunChecks()) |
66 finally: | 68 finally: |
67 sys.path = old_path | 69 sys.path = old_path |
68 | 70 |
69 return results | 71 return results |
OLD | NEW |