summaryrefslogtreecommitdiff
path: root/chromium/tools/resources/PRESUBMIT.py
blob: f07a4a3505ec08649b3daf643f9fd6252b58c155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

USE_PYTHON3 = True


def CheckChangeOnUpload(*args):
  return _CommonChecks(*args)


def CheckChangeOnCommit(*args):
  return _CommonChecks(*args)


def _CommonChecks(input_api, output_api):
  cwd = input_api.PresubmitLocalPath()
  path = input_api.os_path
  files = [path.basename(f.LocalPath()) for f in input_api.AffectedFiles()]

  if any(f for f in files if f.startswith('svgo_presubmit')):
    tests = [path.join(cwd, 'svgo_presubmit_test.py')]
    return input_api.canned_checks.RunUnitTests(input_api,
                                                output_api,
                                                tests,
                                                run_on_python2=False)

  return []