Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: tools/perf/PRESUBMIT.py

Issue 2713553008: Add PRESUBMIT to make sure that perf JSON configs are always up-to-date (Closed)
Patch Set: Address Randy's nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/perf/generate_perf_json.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Presubmit script for changes affecting tools/perf/. 5 """Presubmit script for changes affecting tools/perf/.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
11 import os 11 import os
12 import sys 12 import sys
13 13
14 14
15 def _CommonChecks(input_api, output_api): 15 def _CommonChecks(input_api, output_api):
16 """Performs common checks, which includes running pylint.""" 16 """Performs common checks, which includes running pylint."""
17 results = [] 17 results = []
18 18
19 results.extend(_CheckWprShaFiles(input_api, output_api)) 19 results.extend(_CheckWprShaFiles(input_api, output_api))
20 results.extend(_CheckJson(input_api, output_api)) 20 results.extend(_CheckJson(input_api, output_api))
21 results.extend(_CheckPerfJsonUpToDate(input_api, output_api))
21 results.extend(input_api.RunTests(input_api.canned_checks.GetPylint( 22 results.extend(input_api.RunTests(input_api.canned_checks.GetPylint(
22 input_api, output_api, extra_paths_list=_GetPathsToPrepend(input_api), 23 input_api, output_api, extra_paths_list=_GetPathsToPrepend(input_api),
23 pylintrc='pylintrc'))) 24 pylintrc='pylintrc')))
24 return results 25 return results
25 26
26 27
27 def _GetPathsToPrepend(input_api): 28 def _GetPathsToPrepend(input_api):
28 perf_dir = input_api.PresubmitLocalPath() 29 perf_dir = input_api.PresubmitLocalPath()
29 chromium_src_dir = input_api.os_path.join(perf_dir, '..', '..') 30 chromium_src_dir = input_api.os_path.join(perf_dir, '..', '..')
30 telemetry_dir = input_api.os_path.join( 31 telemetry_dir = input_api.os_path.join(
31 chromium_src_dir, 'third_party', 'catapult', 'telemetry') 32 chromium_src_dir, 'third_party', 'catapult', 'telemetry')
32 experimental_dir = input_api.os_path.join( 33 experimental_dir = input_api.os_path.join(
33 chromium_src_dir, 'third_party', 'catapult', 'experimental') 34 chromium_src_dir, 'third_party', 'catapult', 'experimental')
34 return [ 35 return [
35 telemetry_dir, 36 telemetry_dir,
36 input_api.os_path.join(telemetry_dir, 'third_party', 'mock'), 37 input_api.os_path.join(telemetry_dir, 'third_party', 'mock'),
37 experimental_dir, 38 experimental_dir,
38 ] 39 ]
39 40
40 41
42 def _RunArgs(args, input_api):
43 p = input_api.subprocess.Popen(args, stdout=input_api.subprocess.PIPE,
44 stderr=input_api.subprocess.STDOUT)
45 out, _ = p.communicate()
46 return (out, p.returncode)
47
48
49 def _CheckPerfJsonUpToDate(input_api, output_api):
50 results = []
51 perf_dir = input_api.PresubmitLocalPath()
52 out, return_code = _RunArgs([
53 input_api.python_executable,
54 input_api.os_path.join(perf_dir, 'generate_perf_json.py'),
55 '--validate-only'], input_api)
56 if return_code:
57 results.append(output_api.PresubmitError(
58 'Validating Perf JSON configs failed.', long_text=out))
59 return results
60
61
41 def _CheckWprShaFiles(input_api, output_api): 62 def _CheckWprShaFiles(input_api, output_api):
42 """Check whether the wpr sha files have matching URLs.""" 63 """Check whether the wpr sha files have matching URLs."""
43 old_sys_path = sys.path 64 old_sys_path = sys.path
44 try: 65 try:
45 perf_dir = input_api.PresubmitLocalPath() 66 perf_dir = input_api.PresubmitLocalPath()
46 py_utils_path = os.path.abspath(os.path.join( 67 py_utils_path = os.path.abspath(os.path.join(
47 perf_dir, '..', '..', 'third_party', 'catapult', 'common', 'py_utils')) 68 perf_dir, '..', '..', 'third_party', 'catapult', 'common', 'py_utils'))
48 sys.path.insert(1, py_utils_path) 69 sys.path.insert(1, py_utils_path)
49 from py_utils import cloud_storage # pylint: disable=import-error 70 from py_utils import cloud_storage # pylint: disable=import-error
50 finally: 71 finally:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 def CheckChangeOnUpload(input_api, output_api): 109 def CheckChangeOnUpload(input_api, output_api):
89 report = [] 110 report = []
90 report.extend(_CommonChecks(input_api, output_api)) 111 report.extend(_CommonChecks(input_api, output_api))
91 return report 112 return report
92 113
93 114
94 def CheckChangeOnCommit(input_api, output_api): 115 def CheckChangeOnCommit(input_api, output_api):
95 report = [] 116 report = []
96 report.extend(_CommonChecks(input_api, output_api)) 117 report.extend(_CommonChecks(input_api, output_api))
97 return report 118 return report
OLDNEW
« no previous file with comments | « no previous file | tools/perf/generate_perf_json.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698