OLD | NEW |
---|---|
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 | 5 |
6 def CheckChangeOnUpload(*args): | 6 def CheckChangeOnUpload(*args): |
7 return _CommonChecks(*args) | 7 return _CommonChecks(*args) |
8 | 8 |
9 | 9 |
10 def CheckChangeOnCommit(*args): | 10 def CheckChangeOnCommit(*args): |
11 return _CommonChecks(*args) | 11 return _CommonChecks(*args) |
12 | 12 |
13 | 13 |
14 def _CommonChecks(input_api, output_api): | 14 def _CommonChecks(input_api, output_api): |
15 cwd = input_api.PresubmitLocalPath() | 15 cwd = input_api.PresubmitLocalPath() |
16 path = input_api.os_path | 16 path = input_api.os_path |
17 files = [path.basename(f.LocalPath()) for f in input_api.AffectedFiles()] | 17 files = [path.basename(f.LocalPath()) for f in input_api.AffectedFiles()] |
18 tests = [] | 18 tests = [] |
19 | 19 |
20 if 'css_checker.py' in files: | 20 if 'css_checker.py' in files: |
21 tests.append(path.join(cwd, 'css_checker_test.py')) | 21 tests.append(path.join(cwd, 'css_checker_test.py')) |
22 | 22 |
23 utils_changed = 'regex_check.py' in files or 'test_util.py' in files | 23 utils_changed = 'regex_check.py' in files or 'test_util.py' in files |
24 | 24 |
25 if utils_changed or any(f for f in files if f.startswith('html_checker')): | 25 if utils_changed or any(f for f in files if f.startswith('html_checker')): |
26 tests.append(path.join(cwd, 'html_checker_test.py')) | 26 tests.append(path.join(cwd, 'html_checker_test.py')) |
27 | 27 |
28 if utils_changed or any(f for f in files if f.startswith('js_checker')): | 28 if utils_changed or any(f for f in files if f.startswith('js_checker')): |
29 tests.append(path.join(cwd, 'js_checker_test.py')) | 29 tests.append(path.join(cwd, 'js_checker_test.py')) |
30 tests.append(path.join(cwd, 'js_checker_eslint_test.py')) | |
dpapad
2017/05/31 22:30:20
I am planning to detect .eslintrc.js changes in a
Dan Beam
2017/05/31 22:54:33
Acknowledged.
Dan Beam
2017/05/31 22:54:33
nit:
tests += [path.join(cwd, 'js_checker_%stest.
dpapad
2017/05/31 22:58:10
Even though I acknowledge that this is shorter and
| |
30 | 31 |
31 if utils_changed or any(f for f in files if f.startswith('resource_checker')): | 32 if utils_changed or any(f for f in files if f.startswith('resource_checker')): |
32 tests.append(path.join(cwd, 'resource_checker_test.py')) | 33 tests.append(path.join(cwd, 'resource_checker_test.py')) |
33 | 34 |
34 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) | 35 return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) |
OLD | NEW |