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 """test_expectations.txt presubmit script. | 5 """test_expectations.txt presubmit script. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
8 details on the presubmit API built into gcl. | 8 details on the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 | 13 |
14 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations'] | 14 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations'] |
15 | 15 |
16 def LintTestFiles(input_api, output_api): | 16 def LintTestFiles(input_api, output_api): |
17 current_dir = str(input_api.PresubmitLocalPath()) | 17 current_dir = str(input_api.PresubmitLocalPath()) |
18 tools_dir = os.path.dirname(os.path.abspath(sys.argv[0])) | 18 tools_dir = os.path.dirname(os.path.abspath(sys.argv[0])) |
19 src_dir = os.path.dirname(tools_dir) | 19 src_dir = os.path.dirname(tools_dir) |
20 | 20 |
21 # Set 'webkit/tools/layout_tests' in include path. | |
22 python_paths = [ | |
23 current_dir, | |
24 input_api.os_path.join(src_dir, 'tools', 'python') | |
25 ] | |
26 env = input_api.environ.copy() | |
27 if env.get('PYTHONPATH'): | |
28 python_paths.append(env['PYTHONPATH']) | |
29 env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths) | |
30 args = [ | |
31 input_api.python_executable, | |
32 input_api.os_path.join(src_dir, 'webkit', 'tools', 'layout_tests', | |
33 'run_webkit_tests.py'), '--lint-test-files' | |
34 ] | |
35 subproc = input_api.subprocess.Popen( | 21 subproc = input_api.subprocess.Popen( |
36 args, | 22 [input_api.python_executable, |
37 cwd=current_dir, | 23 input_api.os.path.join(src_dir, 'third_party', 'WebKit', 'Tools', |
38 env=env, | 24 'Scripts', 'lint-test-expectations')], |
39 stdin=input_api.subprocess.PIPE, | 25 stdin=input_api.subprocess.PIPE, |
40 stdout=input_api.subprocess.PIPE, | 26 stdout=input_api.subprocess.PIPE, |
41 stderr=input_api.subprocess.STDOUT) | 27 stderr=input_api.subprocess.STDOUT) |
42 stdout_data = subproc.communicate()[0] | 28 stdout_data = subproc.communicate()[0] |
43 # TODO(ukai): consolidate run_webkit_tests --lint-test-files reports. | 29 # TODO(ukai): consolidate run-webkit-tests --lint-test-files reports. |
Dirk Pranke
2014/09/20 00:57:59
I would delete this comment. If you don't want to
| |
44 is_error = lambda line: (input_api.re.match('^Line:', line) or | 30 is_error = lambda line: (input_api.re.match('^Line:', line) or |
45 input_api.re.search('ERROR Line:', line)) | 31 input_api.re.search('ERROR Line:', line)) |
46 error = filter(is_error, stdout_data.splitlines()) | 32 error = filter(is_error, stdout_data.splitlines()) |
47 if error: | 33 if error: |
48 return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error), | 34 return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error), |
49 long_text=stdout_data)] | 35 long_text=stdout_data)] |
50 return [] | 36 return [] |
51 | 37 |
52 def LintTestExpectations(input_api, output_api): | 38 def LintTestExpectations(input_api, output_api): |
53 for path in input_api.LocalPaths(): | 39 for path in input_api.LocalPaths(): |
54 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: | 40 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: |
55 return LintTestFiles(input_api, output_api) | 41 return LintTestFiles(input_api, output_api) |
56 return [] | 42 return [] |
57 | 43 |
58 | 44 |
59 def CheckChangeOnUpload(input_api, output_api): | 45 def CheckChangeOnUpload(input_api, output_api): |
60 return LintTestExpectations(input_api, output_api) | 46 return LintTestExpectations(input_api, output_api) |
61 | 47 |
62 def CheckChangeOnCommit(input_api, output_api): | 48 def CheckChangeOnCommit(input_api, output_api): |
63 return LintTestExpectations(input_api, output_api) | 49 return LintTestExpectations(input_api, output_api) |
OLD | NEW |