| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 """test_expectations.txt presubmit script. | |
| 6 | |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | |
| 8 for more details on the presubmit API built into depot_tools. | |
| 9 """ | |
| 10 | |
| 11 import os | |
| 12 import sys | |
| 13 | |
| 14 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations'] | |
| 15 | |
| 16 def LintTestFiles(input_api, output_api): | |
| 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 | |
| 21 subproc = input_api.subprocess.Popen( | |
| 22 [input_api.python_executable, | |
| 23 input_api.os.path.join(src_dir, 'third_party', 'WebKit', 'Tools', | |
| 24 'Scripts', 'lint-test-expectations')], | |
| 25 stdin=input_api.subprocess.PIPE, | |
| 26 stdout=input_api.subprocess.PIPE, | |
| 27 stderr=input_api.subprocess.STDOUT) | |
| 28 stdout_data = subproc.communicate()[0] | |
| 29 is_error = lambda line: (input_api.re.match('^Line:', line) or | |
| 30 input_api.re.search('ERROR Line:', line)) | |
| 31 error = filter(is_error, stdout_data.splitlines()) | |
| 32 if error: | |
| 33 return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error), | |
| 34 long_text=stdout_data)] | |
| 35 return [] | |
| 36 | |
| 37 def LintTestExpectations(input_api, output_api): | |
| 38 for path in input_api.LocalPaths(): | |
| 39 if input_api.os_path.basename(path) in TEST_EXPECTATIONS_FILENAMES: | |
| 40 return LintTestFiles(input_api, output_api) | |
| 41 return [] | |
| 42 | |
| 43 | |
| 44 def CheckChangeOnUpload(input_api, output_api): | |
| 45 return LintTestExpectations(input_api, output_api) | |
| 46 | |
| 47 def CheckChangeOnCommit(input_api, output_api): | |
| 48 return LintTestExpectations(input_api, output_api) | |
| OLD | NEW |