Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / content / test / PRESUBMIT.py
blob76d13fc56801359047f03a8a4badc4fcd81f1b6d
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
8 for more details on the presubmit API built into depot_tools.
9 """
11 import os
12 import sys
14 TEST_EXPECTATIONS_FILENAMES = ['test_expectations.txt', 'TestExpectations']
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)
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 []
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 []
44 def CheckChangeOnUpload(input_api, output_api):
45 return LintTestExpectations(input_api, output_api)
47 def CheckChangeOnCommit(input_api, output_api):
48 return LintTestExpectations(input_api, output_api)