• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 the V8 project authors. All rights reserved.
2# Copyright 2015 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# This line is 'magic' in that git-cl looks for it to decide whether to
7# use Python3 instead of Python2 when running the code in this file.
8USE_PYTHON3 = True
9
10
11def _CommonChecks(input_api, output_api):
12  results = []
13
14  # Run Pylint over the files in the directory.
15  pylint_checks = input_api.canned_checks.GetPylint(input_api, output_api)
16  results.extend(input_api.RunTests(pylint_checks))
17
18  # Run the MB unittests.
19  results.extend(
20      input_api.canned_checks.RunUnitTestsInDirectory(input_api, output_api,
21                                                      '.', [r'^.+_test\.py$']))
22
23  # Validate the format of the mb_config.pyl file.
24  cmd = [input_api.python_executable, 'mb.py', 'validate']
25  kwargs = {'cwd': input_api.PresubmitLocalPath()}
26  results.extend(input_api.RunTests([
27      input_api.Command(name='mb_validate',
28                        cmd=cmd, kwargs=kwargs,
29                        message=output_api.PresubmitError)]))
30
31  is_mb_config = (lambda filepath: 'mb_config.pyl' in filepath.LocalPath())
32  results.extend(
33      input_api.canned_checks.CheckLongLines(
34          input_api, output_api, maxlen=80, source_file_filter=is_mb_config))
35
36  return results
37
38
39def CheckChangeOnUpload(input_api, output_api):
40  return _CommonChecks(input_api, output_api)
41
42
43def CheckChangeOnCommit(input_api, output_api):
44  return _CommonChecks(input_api, output_api)
45