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 |
| 12 import sys |
| 13 |
11 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations'] | 14 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations'] |
12 | 15 |
13 def LintTestFiles(input_api, output_api): | 16 def LintTestFiles(input_api, output_api): |
14 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])) |
| 19 src_dir = os.path.dirname(tools_dir) |
| 20 |
15 # Set 'webkit/tools/layout_tests' in include path. | 21 # Set 'webkit/tools/layout_tests' in include path. |
16 python_paths = [ | 22 python_paths = [ |
17 current_dir, | 23 current_dir, |
18 input_api.os_path.join(current_dir, '..', '..', '..', 'tools', 'python') | 24 input_api.os_path.join(src_dir, 'tools', 'python') |
19 ] | 25 ] |
20 env = input_api.environ.copy() | 26 env = input_api.environ.copy() |
21 if env.get('PYTHONPATH'): | 27 if env.get('PYTHONPATH'): |
22 python_paths.append(env['PYTHONPATH']) | 28 python_paths.append(env['PYTHONPATH']) |
23 env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths) | 29 env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths) |
24 args = [ | 30 args = [ |
25 input_api.python_executable, | 31 input_api.python_executable, |
26 input_api.os_path.join(current_dir, 'run_webkit_tests.py'), | 32 input_api.os_path.join(src_dir, 'webkit', 'tools', 'layout_tests', |
27 '--lint-test-files' | 33 'run_webkit_tests.py'), '--lint-test-files' |
28 ] | 34 ] |
29 subproc = input_api.subprocess.Popen( | 35 subproc = input_api.subprocess.Popen( |
30 args, | 36 args, |
31 cwd=current_dir, | 37 cwd=current_dir, |
32 env=env, | 38 env=env, |
33 stdin=input_api.subprocess.PIPE, | 39 stdin=input_api.subprocess.PIPE, |
34 stdout=input_api.subprocess.PIPE, | 40 stdout=input_api.subprocess.PIPE, |
35 stderr=input_api.subprocess.STDOUT) | 41 stderr=input_api.subprocess.STDOUT) |
36 stdout_data = subproc.communicate()[0] | 42 stdout_data = subproc.communicate()[0] |
37 # TODO(ukai): consolidate run_webkit_tests --lint-test-files reports. | 43 # TODO(ukai): consolidate run_webkit_tests --lint-test-files reports. |
(...skipping 10 matching lines...) Expand all Loading... |
48 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: | 54 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: |
49 return LintTestFiles(input_api, output_api) | 55 return LintTestFiles(input_api, output_api) |
50 return [] | 56 return [] |
51 | 57 |
52 | 58 |
53 def CheckChangeOnUpload(input_api, output_api): | 59 def CheckChangeOnUpload(input_api, output_api): |
54 return LintTestExpectations(input_api, output_api) | 60 return LintTestExpectations(input_api, output_api) |
55 | 61 |
56 def CheckChangeOnCommit(input_api, output_api): | 62 def CheckChangeOnCommit(input_api, output_api): |
57 return LintTestExpectations(input_api, output_api) | 63 return LintTestExpectations(input_api, output_api) |
OLD | NEW |