xref: /aosp_15_r20/external/cronet/build/skia_gold_common/PRESUBMIT.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2020 The Chromium Authors
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 //build/skia_gold_common/.
5
6See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
7for more details on the presubmit API built into depot_tools.
8"""
9
10
11PRESUBMIT_VERSION = '2.0.0'
12
13
14def _GetSkiaGoldEnv(input_api):
15  """Gets the common environment for running Skia Gold tests."""
16  build_path = input_api.os_path.join(input_api.PresubmitLocalPath(), '..')
17  skia_gold_env = dict(input_api.environ)
18  skia_gold_env.update({
19      'PYTHONPATH': build_path,
20      'PYTHONDONTWRITEBYTECODE': '1',
21  })
22  return skia_gold_env
23
24
25def CheckSkiaGoldCommonUnittests(input_api, output_api):
26  """Runs the unittests for the build/skia_gold_common/ directory."""
27  return input_api.canned_checks.RunUnitTestsInDirectory(
28      input_api,
29      output_api,
30      input_api.PresubmitLocalPath(), [r'^.+_unittest\.py$'],
31      env=_GetSkiaGoldEnv(input_api))
32
33
34def CheckPylint(input_api, output_api):
35  """Runs pylint on all directory content and subdirectories."""
36  return input_api.canned_checks.RunPylint(input_api, output_api, version='2.7')
37