Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: webkit/tools/layout_tests/PRESUBMIT.py

Issue 160442: Add presubmit check to lint test files. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/layout_tests/PRESUBMIT.py
===================================================================
--- webkit/tools/layout_tests/PRESUBMIT.py (revision 0)
+++ webkit/tools/layout_tests/PRESUBMIT.py (revision 0)
@@ -0,0 +1,57 @@
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""test_expectations.txt presubmit script.
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
+details on the presubmit API built into gcl.
+"""
+
+TEST_EXPECTATIONS = 'test_expectations.txt'
+
+def LintTestFiles(input_api, output_api):
+ current_dir = input_api.PresubmitLocalPath()
+ # Set 'webkit/tools/layout_tests' in include path.
+ python_paths = [
+ current_dir,
+ input_api.os_path.join(current_dir, '..', '..', '..', 'tools', 'python')
+ ]
+ env = input_api.environ.copy()
+ if env.get('PYTHONPATH'):
+ python_paths.append(env['PYTHONPATH'])
+ env['PYTHONPATH'] = input_api.os_path.pathsep.join(python_paths)
+ args = [
+ input_api.python_executable,
+ input_api.os_path.join(current_dir, 'run_webkit_tests.py'),
+ '--lint-test-files'
+ ]
+ subproc = input_api.subprocess.Popen(
+ args,
+ cwd=current_dir,
+ env=env,
+ stdin=input_api.subprocess.PIPE,
+ stdout=input_api.subprocess.PIPE,
+ stderr=input_api.subprocess.STDOUT)
+ stdoutdata = subproc.communicate()[0]
+ # TODO(ukai): consolidate run_webkit_tests --lint-test-files reports.
+ is_error = lambda line: (input_api.re.match('^Line:', line) or
+ input_api.re.search('ERROR Line:', line))
+ error = filter(is_error, stdoutdata.splitlines())
+ if error:
+ return [output_api.PresubmitError('Lint error\n%s' % '\n'.join(error),
+ long_text=stdoutdata)]
+ return []
+
+def LintTestExpectations(input_api, output_api):
+ for path in input_api.LocalPaths():
+ if TEST_EXPECTATIONS == input_api.os_path.basename(path):
+ return LintTestFiles(input_api, output_api)
+ return []
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ return LintTestExpectations(input_api, output_api)
+
+def CheckChangeOnCommit(input_api, output_api):
+ return LintTestExpectations(input_api, output_api)
Property changes on: webkit/tools/layout_tests/PRESUBMIT.py
___________________________________________________________________
Name: svn:eol-style
+ LF
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698