PRESUBMIT.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.
  4. """Top-level presubmit script for testing.
  5. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
  6. for more details on the presubmit API built into depot_tools.
  7. """
  8. USE_PYTHON3 = True
  9. def CommonChecks(input_api, output_api):
  10. testing_env = dict(input_api.environ)
  11. testing_env.update({
  12. 'PYTHONPATH': input_api.PresubmitLocalPath(),
  13. 'PYTHONDONTWRITEBYTECODE': '1',
  14. })
  15. output = []
  16. output.extend(input_api.canned_checks.RunUnitTestsInDirectory(
  17. input_api,
  18. output_api,
  19. '.',
  20. [r'^.+_unittest\.py$'],
  21. run_on_python2=False,
  22. run_on_python3=USE_PYTHON3,
  23. skip_shebang_check=True))
  24. output.extend(input_api.canned_checks.RunUnitTestsInDirectory(
  25. input_api,
  26. output_api,
  27. input_api.os_path.join(input_api.PresubmitLocalPath(),
  28. 'unexpected_passes_common'),
  29. [r'^.+_unittest\.py$'],
  30. env=testing_env,
  31. run_on_python2=False,
  32. run_on_python3=USE_PYTHON3,
  33. skip_shebang_check=True))
  34. files_to_skip = input_api.DEFAULT_FILES_TO_SKIP
  35. if input_api.is_windows:
  36. # These scripts don't run on Windows and should not be linted on Windows -
  37. # trying to do so will lead to spurious errors.
  38. files_to_skip += ('xvfb.py', '.*host_info.py')
  39. output.extend(input_api.canned_checks.RunPylint(
  40. input_api,
  41. output_api,
  42. files_to_skip=files_to_skip,
  43. version='2.7'))
  44. return output
  45. def CheckChangeOnUpload(input_api, output_api):
  46. return CommonChecks(input_api, output_api)
  47. def CheckChangeOnCommit(input_api, output_api):
  48. return CommonChecks(input_api, output_api)