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. | 21 # Set 'content/test' in include path. |
22 python_paths = [ | 22 python_paths = [ |
23 current_dir, | 23 current_dir, |
24 input_api.os_path.join(src_dir, 'tools', 'python') | 24 input_api.os_path.join(src_dir, 'tools', 'python') |
25 ] | 25 ] |
26 env = input_api.environ.copy() | 26 env = input_api.environ.copy() |
27 if env.get('PYTHONPATH'): | 27 if env.get('PYTHONPATH'): |
28 python_paths.append(env['PYTHONPATH']) | 28 python_paths.append(env['PYTHONPATH']) |
29 env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths) | 29 env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths) |
30 args = [ | 30 args = [ |
31 input_api.python_executable, | 31 input_api.python_executable, |
32 input_api.os_path.join(src_dir, 'webkit', 'tools', 'layout_tests', | 32 input_api.os_path.join(src_dir, 'third_party', 'WebKit', 'Tools', |
33 'run_webkit_tests.py'), '--lint-test-files' | 33 'Scripts', 'run-webkit-tests'), '--lint-test-files' |
34 ] | 34 ] |
35 subproc = input_api.subprocess.Popen( | 35 subproc = input_api.subprocess.Popen( |
36 args, | 36 args, |
37 cwd=current_dir, | 37 cwd=current_dir, |
38 env=env, | 38 env=env, |
39 stdin=input_api.subprocess.PIPE, | 39 stdin=input_api.subprocess.PIPE, |
40 stdout=input_api.subprocess.PIPE, | 40 stdout=input_api.subprocess.PIPE, |
41 stderr=input_api.subprocess.STDOUT) | 41 stderr=input_api.subprocess.STDOUT) |
42 stdout_data = subproc.communicate()[0] | 42 stdout_data = subproc.communicate()[0] |
Dirk Pranke
2014/09/19 18:27:34
If we're changing this at all, we might as well ch
| |
43 # TODO(ukai): consolidate run_webkit_tests --lint-test-files reports. | 43 # TODO(ukai): consolidate run-webkit-tests --lint-test-files reports. |
44 is_error = lambda line: (input_api.re.match('^Line:', line) or | 44 is_error = lambda line: (input_api.re.match('^Line:', line) or |
45 input_api.re.search('ERROR Line:', line)) | 45 input_api.re.search('ERROR Line:', line)) |
46 error = filter(is_error, stdout_data.splitlines()) | 46 error = filter(is_error, stdout_data.splitlines()) |
47 if error: | 47 if error: |
48 return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error), | 48 return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error), |
49 long_text=stdout_data)] | 49 long_text=stdout_data)] |
50 return [] | 50 return [] |
51 | 51 |
52 def LintTestExpectations(input_api, output_api): | 52 def LintTestExpectations(input_api, output_api): |
53 for path in input_api.LocalPaths(): | 53 for path in input_api.LocalPaths(): |
54 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: | 54 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: |
55 return LintTestFiles(input_api, output_api) | 55 return LintTestFiles(input_api, output_api) |
56 return [] | 56 return [] |
57 | 57 |
58 | 58 |
59 def CheckChangeOnUpload(input_api, output_api): | 59 def CheckChangeOnUpload(input_api, output_api): |
60 return LintTestExpectations(input_api, output_api) | 60 return LintTestExpectations(input_api, output_api) |
61 | 61 |
62 def CheckChangeOnCommit(input_api, output_api): | 62 def CheckChangeOnCommit(input_api, output_api): |
63 return LintTestExpectations(input_api, output_api) | 63 return LintTestExpectations(input_api, output_api) |
OLD | NEW |