PRESUBMIT.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright 2016 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. """Presubmit for android_webview/tools."""
  5. USE_PYTHON3 = True
  6. def _GetPythonUnitTests(input_api, output_api):
  7. return input_api.canned_checks.GetUnitTestsRecursively(
  8. input_api,
  9. output_api,
  10. input_api.PresubmitLocalPath(),
  11. files_to_check=['.*_test\\.py$'],
  12. files_to_skip=[],
  13. run_on_python2=False)
  14. def CommonChecks(input_api, output_api):
  15. """Presubmit checks run on both upload and commit.
  16. """
  17. checks = []
  18. src_root = input_api.os_path.join(input_api.PresubmitLocalPath(), '..', '..')
  19. checks.extend(
  20. input_api.canned_checks.GetPylint(
  21. input_api,
  22. output_api,
  23. pylintrc='pylintrc',
  24. disabled_warnings=[
  25. 'R0801', # suppress pylint duplicate code false positive
  26. ],
  27. # Allows pylint to find dependencies imported by scripts in this
  28. # directory.
  29. extra_paths_list=[
  30. input_api.os_path.join(src_root, 'build', 'android'),
  31. input_api.os_path.join(src_root, 'build', 'android', 'gyp'),
  32. input_api.os_path.join(src_root, 'third_party', 'catapult',
  33. 'common', 'py_utils'),
  34. input_api.os_path.join(src_root, 'third_party', 'catapult',
  35. 'devil'),
  36. ],
  37. version='2.7'))
  38. checks.extend(_GetPythonUnitTests(input_api, output_api))
  39. return input_api.RunTests(checks, False)
  40. def CheckChangeOnUpload(input_api, output_api):
  41. """Presubmit checks on CL upload."""
  42. return CommonChecks(input_api, output_api)
  43. def CheckChangeOnCommit(input_api, output_api):
  44. """Presubmit checks on commit."""
  45. return CommonChecks(input_api, output_api)