PRESUBMIT.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright 2022 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 script for changes affecting tools/json_data_generator/
  5. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
  6. for more details about the presubmit API built into depot_tools.
  7. """
  8. import os
  9. USE_PYTHON3 = True
  10. TEST_PATTERNS = [r'.+_test.py$']
  11. def _CommonChecks(input_api, output_api):
  12. env = os.environ
  13. pythonpath = [os.path.join(os.getcwd(), '..')]
  14. if 'PYTHONPATH' in env:
  15. pythonpath.append(env.get('PYTHONPATH'))
  16. env['PYTHONPATH'] = input_api.os_path.pathsep.join((pythonpath))
  17. return input_api.canned_checks.RunUnitTestsInDirectory(
  18. input_api,
  19. output_api,
  20. '.',
  21. files_to_check=TEST_PATTERNS,
  22. env=env,
  23. run_on_python2=False,
  24. skip_shebang_check=True)
  25. def CheckChangeOnUpload(input_api, output_api):
  26. return _CommonChecks(input_api, output_api)
  27. def CheckChangeOnCommit(input_api, output_api):
  28. return _CommonChecks(input_api, output_api)