cc: Optimise shared raster tile handling in raster tile priority queue.
[chromium-blink-merge.git] / tools / perf / PRESUBMIT.py
blob2c269c882abe4c27387f4ace85942445e8e78596
1 # Copyright 2012 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.
5 """Presubmit script for changes affecting tools/perf/.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl (and git-cl).
9 """
11 import os
12 import sys
14 PYLINT_BLACKLIST = []
15 PYLINT_DISABLED_WARNINGS = [
16 'R0923', # Interface not implemented
17 'R0201', # Method could be a function
18 'E1101', # Non-existent member is accessed.
22 def _CommonChecks(input_api, output_api):
23 """Performs common checks, which includes running pylint."""
24 results = []
25 old_sys_path = sys.path
26 try:
27 # Modules in tools/perf depend on telemetry.
28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path
29 results.extend(input_api.canned_checks.RunPylint(
30 input_api, output_api,
31 black_list=PYLINT_BLACKLIST,
32 disabled_warnings=PYLINT_DISABLED_WARNINGS))
33 results.extend(_CheckJson(input_api, output_api))
34 finally:
35 sys.path = old_sys_path
36 return results
39 def _CheckJson(input_api, output_api):
40 """Checks whether JSON files in this change can be parsed."""
41 for affected_file in input_api.AffectedFiles(include_deletes=False):
42 filename = affected_file.AbsoluteLocalPath()
43 if os.path.splitext(filename)[1] != '.json':
44 continue
45 try:
46 input_api.json.load(open(filename))
47 except ValueError:
48 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)]
49 return []
52 def CheckChangeOnUpload(input_api, output_api):
53 report = []
54 report.extend(_CommonChecks(input_api, output_api))
55 return report
58 def CheckChangeOnCommit(input_api, output_api):
59 report = []
60 report.extend(_CommonChecks(input_api, output_api))
61 return report