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 checks HTML/CSS/JS files in resources/ and ui/webui/. | 7 This script currently checks HTML/CSS/JS files in resources/ and ui/webui/. |
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 depot_tools, and see | 10 for more details about the presubmit API built into depot_tools, and see |
(...skipping 13 matching lines...) Expand all Loading... |
24 def _CommonChecks(input_api, output_api): | 24 def _CommonChecks(input_api, output_api): |
25 """Checks common to both upload and commit.""" | 25 """Checks common to both upload and commit.""" |
26 results = [] | 26 results = [] |
27 | 27 |
28 path = input_api.os_path | 28 path = input_api.os_path |
29 cwd = input_api.PresubmitLocalPath() | 29 cwd = input_api.PresubmitLocalPath() |
30 resources = path.join(cwd, 'resources') | 30 resources = path.join(cwd, 'resources') |
31 webui = path.join(cwd, 'ui', 'webui') | 31 webui = path.join(cwd, 'ui', 'webui') |
32 | 32 |
33 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()) | 33 affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()) |
34 would_affect_tests = ( | 34 |
| 35 would_affect_tests = [ |
35 path.join(cwd, 'PRESUBMIT.py'), | 36 path.join(cwd, 'PRESUBMIT.py'), |
36 path.join(cwd, 'test_presubmit.py'), | 37 path.join(cwd, 'test_presubmit.py'), |
37 path.join(cwd, 'web_dev_style', 'css_checker.py'), | 38 ] |
38 path.join(cwd, 'web_dev_style', 'html_checker.py'), | 39 would_affect_tests += input_api.glob(path.join(cwd, 'web_dev_style', '*.py')) |
39 path.join(cwd, 'web_dev_style', 'js_checker.py'), | 40 |
40 ) | |
41 if any(f for f in affected_files if f in would_affect_tests): | 41 if any(f for f in affected_files if f in would_affect_tests): |
42 tests = [path.join(cwd, 'test_presubmit.py')] | 42 tests = [path.join(cwd, 'test_presubmit.py')] |
43 results.extend( | 43 results.extend( |
44 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) | 44 input_api.canned_checks.RunUnitTests(input_api, output_api, tests)) |
45 | 45 |
46 import sys | 46 import sys |
47 old_path = sys.path | 47 old_path = sys.path |
48 | 48 |
49 try: | 49 try: |
50 sys.path = [cwd] + old_path | 50 sys.path = [cwd] + old_path |
(...skipping 15 matching lines...) Expand all Loading... |
66 results.extend(css_checker.CSSChecker( | 66 results.extend(css_checker.CSSChecker( |
67 input_api, output_api, file_filter=is_resource).RunChecks()) | 67 input_api, output_api, file_filter=is_resource).RunChecks()) |
68 results.extend(html_checker.HtmlChecker( | 68 results.extend(html_checker.HtmlChecker( |
69 input_api, output_api, file_filter=is_resource).RunChecks()) | 69 input_api, output_api, file_filter=is_resource).RunChecks()) |
70 results.extend(js_checker.JSChecker( | 70 results.extend(js_checker.JSChecker( |
71 input_api, output_api, file_filter=is_resource).RunChecks()) | 71 input_api, output_api, file_filter=is_resource).RunChecks()) |
72 finally: | 72 finally: |
73 sys.path = old_path | 73 sys.path = old_path |
74 | 74 |
75 return results | 75 return results |
OLD | NEW |