PRESUBMIT.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 2017 The LibYuv Project Authors. All rights reserved.
  2. #
  3. # Use of this source code is governed by a BSD-style license
  4. # that can be found in the LICENSE file in the root of the source
  5. # tree. An additional intellectual property rights grant can be found
  6. # in the file PATENTS. All contributing project authors may
  7. # be found in the AUTHORS file in the root of the source tree.
  8. import os
  9. def _RunPythonTests(input_api, output_api):
  10. def join(*args):
  11. return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
  12. test_directories = [
  13. root for root, _, files in os.walk(join('tools_libyuv'))
  14. if any(f.endswith('_test.py') for f in files)
  15. ]
  16. tests = []
  17. for directory in test_directories:
  18. tests.extend(
  19. input_api.canned_checks.GetUnitTestsInDirectory(
  20. input_api,
  21. output_api,
  22. directory,
  23. whitelist=[r'.+_test\.py$']))
  24. return input_api.RunTests(tests, parallel=True)
  25. def _CommonChecks(input_api, output_api):
  26. """Checks common to both upload and commit."""
  27. results = []
  28. results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
  29. black_list=(r'^base[\\\/].*\.py$',
  30. r'^build[\\\/].*\.py$',
  31. r'^buildtools[\\\/].*\.py$',
  32. r'^ios[\\\/].*\.py$',
  33. r'^out.*[\\\/].*\.py$',
  34. r'^testing[\\\/].*\.py$',
  35. r'^third_party[\\\/].*\.py$',
  36. r'^tools[\\\/].*\.py$',
  37. # TODO(kjellander): should arguably be checked.
  38. r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$',
  39. r'^xcodebuild.*[\\\/].*\.py$',),
  40. disabled_warnings=['F0401', # Failed to import x
  41. 'E0611', # No package y in x
  42. 'W0232', # Class has no __init__ method
  43. ],
  44. pylintrc='pylintrc'))
  45. results.extend(_RunPythonTests(input_api, output_api))
  46. return results
  47. def CheckChangeOnUpload(input_api, output_api):
  48. results = []
  49. results.extend(_CommonChecks(input_api, output_api))
  50. results.extend(
  51. input_api.canned_checks.CheckGNFormatted(input_api, output_api))
  52. return results
  53. def CheckChangeOnCommit(input_api, output_api):
  54. results = []
  55. results.extend(_CommonChecks(input_api, output_api))
  56. results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
  57. results.extend(input_api.canned_checks.CheckChangeWasUploaded(
  58. input_api, output_api))
  59. results.extend(input_api.canned_checks.CheckChangeHasDescription(
  60. input_api, output_api))
  61. return results