2013-01-09 07:49:57 +04:00
|
|
|
# Copyright (c) 2013 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.
|
|
|
|
|
|
|
|
"""Presubmit script for android buildbot.
|
|
|
|
|
|
|
|
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
|
|
|
|
details on the presubmit API built into gcl.
|
|
|
|
"""
|
|
|
|
|
2013-01-17 02:52:22 +04:00
|
|
|
_DELETIONS_ONLY_FILES = (
|
|
|
|
'build/android/findbugs_filter/findbugs_known_bugs.txt',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def _CheckDeletionsOnlyFiles(input_api, output_api):
|
|
|
|
"""Check that a certain listed files only have deletions.
|
|
|
|
"""
|
2013-03-15 00:57:23 +04:00
|
|
|
warnings = []
|
2013-01-17 02:52:22 +04:00
|
|
|
for f in input_api.AffectedFiles():
|
|
|
|
if f.LocalPath() in _DELETIONS_ONLY_FILES:
|
|
|
|
if f.ChangedContents():
|
2013-03-15 00:57:23 +04:00
|
|
|
warnings.append(f.LocalPath())
|
2013-01-17 02:52:22 +04:00
|
|
|
results = []
|
2013-03-15 00:57:23 +04:00
|
|
|
if warnings:
|
|
|
|
results.append(output_api.PresubmitPromptWarning(
|
|
|
|
'Following files should only contain deletions.', warnings))
|
2013-01-17 02:52:22 +04:00
|
|
|
return results
|
|
|
|
|
|
|
|
|
2013-01-09 07:49:57 +04:00
|
|
|
def CommonChecks(input_api, output_api):
|
|
|
|
output = []
|
|
|
|
|
|
|
|
def J(*dirs):
|
|
|
|
"""Returns a path relative to presubmit directory."""
|
|
|
|
return input_api.os_path.join(input_api.PresubmitLocalPath(), *dirs)
|
|
|
|
|
|
|
|
output.extend(input_api.canned_checks.RunPylint(
|
|
|
|
input_api,
|
|
|
|
output_api,
|
2014-06-25 03:38:17 +04:00
|
|
|
black_list=[r'pylib/symbols/.*\.py$', r'gyp/.*\.py$', r'gn/.*\.py'],
|
2013-01-14 14:37:12 +04:00
|
|
|
extra_paths_list=[
|
2013-06-08 03:14:39 +04:00
|
|
|
J(), J('..', '..', 'third_party', 'android_testrunner'),
|
|
|
|
J('buildbot')]))
|
2014-03-21 03:09:28 +04:00
|
|
|
output.extend(input_api.canned_checks.RunPylint(
|
|
|
|
input_api,
|
|
|
|
output_api,
|
2014-06-25 03:38:17 +04:00
|
|
|
white_list=[r'gyp/.*\.py$', r'gn/.*\.py'],
|
|
|
|
extra_paths_list=[J('gyp'), J('gn')]))
|
2013-01-09 07:49:57 +04:00
|
|
|
|
|
|
|
output.extend(input_api.canned_checks.RunUnitTestsInDirectory(
|
|
|
|
input_api, output_api, J('buildbot', 'tests')))
|
2014-07-11 04:20:34 +04:00
|
|
|
|
|
|
|
pylib_test_env = dict(input_api.environ)
|
|
|
|
pylib_test_env.update({
|
|
|
|
'PYTHONPATH': input_api.PresubmitLocalPath(),
|
|
|
|
'PYTHONDONTWRITEBYTECODE': '1',
|
|
|
|
})
|
|
|
|
output.extend(input_api.canned_checks.RunUnitTests(
|
|
|
|
input_api,
|
|
|
|
output_api,
|
|
|
|
unit_tests=[
|
2014-08-05 20:05:13 +04:00
|
|
|
J('pylib', 'device', 'device_utils_test.py'),
|
|
|
|
J('pylib', 'gtest', 'test_package_test.py'),
|
|
|
|
],
|
2014-07-11 04:20:34 +04:00
|
|
|
env=pylib_test_env))
|
2013-01-17 02:52:22 +04:00
|
|
|
output.extend(_CheckDeletionsOnlyFiles(input_api, output_api))
|
2013-01-09 07:49:57 +04:00
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def CheckChangeOnUpload(input_api, output_api):
|
|
|
|
return CommonChecks(input_api, output_api)
|
|
|
|
|
|
|
|
|
|
|
|
def CheckChangeOnCommit(input_api, output_api):
|
|
|
|
return CommonChecks(input_api, output_api)
|