Probably broke Win7 Tests (dbg)(6). http://build.chromium.org/p/chromium.win/builders...
[chromium-blink-merge.git] / webkit / tools / layout_tests / PRESUBMIT.py
blob713d47e3be9bf2058d9b4fc4d0b01d23d6ac2f82
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
3 # found in the LICENSE file.
5 """test_expectations.txt presubmit script.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
8 details on the presubmit API built into gcl.
9 """
11 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations']
13 def LintTestFiles(input_api, output_api):
14 current_dir = str(input_api.PresubmitLocalPath())
15 # Set 'webkit/tools/layout_tests' in include path.
16 python_paths = [
17 current_dir,
18 input_api.os_path.join(current_dir, '..', '..', '..', 'tools', 'python')
20 env = input_api.environ.copy()
21 if env.get('PYTHONPATH'):
22 python_paths.append(env['PYTHONPATH'])
23 env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths)
24 args = [
25 input_api.python_executable,
26 input_api.os_path.join(current_dir, 'run_webkit_tests.py'),
27 '--lint-test-files'
29 subproc = input_api.subprocess.Popen(
30 args,
31 cwd=current_dir,
32 env=env,
33 stdin=input_api.subprocess.PIPE,
34 stdout=input_api.subprocess.PIPE,
35 stderr=input_api.subprocess.STDOUT)
36 stdout_data = subproc.communicate()[0]
37 # TODO(ukai): consolidate run_webkit_tests --lint-test-files reports.
38 is_error = lambda line: (input_api.re.match('^Line:', line) or
39 input_api.re.search('ERROR Line:', line))
40 error = filter(is_error, stdout_data.splitlines())
41 if error:
42 return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error),
43 long_text=stdout_data)]
44 return []
46 def LintTestExpectations(input_api, output_api):
47 for path in input_api.LocalPaths():
48 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES:
49 return LintTestFiles(input_api, output_api)
50 return []
53 def CheckChangeOnUpload(input_api, output_api):
54 return LintTestExpectations(input_api, output_api)
56 def CheckChangeOnCommit(input_api, output_api):
57 return LintTestExpectations(input_api, output_api)