blob: 76c1c39fa0a6343d8ecf4561c2796d634e574ffa [file] [log] [blame]
Lann Martin46361ee2019-03-14 15:30:47 -06001# Copyright 2019 The Chromium OS Authors. All rights reserved.
David Burgerc0effc22020-03-04 08:27:07 -07002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
Lann Martin46361ee2019-03-14 15:30:47 -06004
recipe-roller4202bc62020-09-17 17:38:22 -07005import git_cl
6
Lann Martin46361ee2019-03-14 15:30:47 -06007
8def CommonChecks(input_api, output_api):
9 results = []
10
11 # recipes.py test run
12 results += input_api.RunTests([
13 input_api.Command(
14 name='recipes test',
15 cmd=[input_api.python_executable, 'recipes.py', 'test', 'run'],
16 kwargs={},
17 message=output_api.PresubmitError,
18 )
19 ])
20
recipe-roller4202bc62020-09-17 17:38:22 -070021 # Python formatting issues are errors, but we need to ignore recipes.py, which
22 # we do not control.
23 bad_format = False
24 cmd = [
25 '-C',
26 input_api.change.RepositoryRoot(), 'cl', 'format', '--dry-run',
27 '--presubmit', '--python', '--no-clang-format', '--diff'
28 ]
29 code, out = git_cl.RunGitWithCode(cmd, suppress_stderr=True)
30 for line in out.splitlines():
31 if line.startswith('--- ') or line.startswith('+++ '):
32 if not ' recipes.py\t' in line:
33 bad_format = True
34 break
35
36 if bad_format:
37 results += input_api.canned_checks.CheckPatchFormatted(
38 input_api, output_api, check_python=True, check_clang_format=False,
39 result_factory=output_api.PresubmitError)
Andrew Lamb9b2d0862019-04-03 16:38:52 -060040
Lann Martin46361ee2019-03-14 15:30:47 -060041 return results
42
43
44CheckChangeOnUpload = CommonChecks
45CheckChangeOnCommit = CommonChecks