OLD | NEW |
---|---|
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 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 results = [] | 24 results = [] |
25 old_sys_path = sys.path | 25 old_sys_path = sys.path |
26 try: | 26 try: |
27 # Modules in tools/perf depend on telemetry. | 27 # Modules in tools/perf depend on telemetry. |
28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path | 28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path |
29 results.extend(input_api.canned_checks.RunPylint( | 29 results.extend(input_api.canned_checks.RunPylint( |
30 input_api, output_api, | 30 input_api, output_api, |
31 black_list=PYLINT_BLACKLIST, | 31 black_list=PYLINT_BLACKLIST, |
32 disabled_warnings=PYLINT_DISABLED_WARNINGS)) | 32 disabled_warnings=PYLINT_DISABLED_WARNINGS)) |
33 results.extend(_CheckJson(input_api, output_api)) | 33 results.extend(_CheckJson(input_api, output_api)) |
34 results.extend(_CheckWprShaFiles(input_api, output_api)) | |
34 finally: | 35 finally: |
35 sys.path = old_sys_path | 36 sys.path = old_sys_path |
36 return results | 37 return results |
37 | 38 |
38 | 39 |
40 def _CheckWprShaFiles(input_api, output_api): | |
41 """Check whether the wpr sha files have matching URLs.""" | |
42 from telemetry.util import cloud_storage | |
43 results = [] | |
44 for affected_file in input_api.AffectedFiles(include_deletes=False): | |
45 filename = affected_file.AbsoluteLocalPath() | |
46 if not filename.endswith('wpr.sha1'): | |
47 continue | |
48 is_wpr_file_uploaded = False | |
slamm
2015/02/24 20:51:19
Not needed.
nednguyen
2015/02/24 20:57:46
Done.
| |
49 expected_hash = cloud_storage.ReadHash(filename) | |
50 is_wpr_file_uploaded = any( | |
51 cloud_storage.Exists(bucket, expected_hash) | |
52 for bucket in cloud_storage.BUCKET_ALIASES.itervalues()) | |
53 if not is_wpr_file_uploaded: | |
54 wpr_filename = filename[:-5] | |
55 results.append(output_api.PresubmitError( | |
56 'There is no URLs matched for wpr sha file %s.\n' | |
57 'You can upload your new wpr archive file with the command:\n' | |
58 'depot_tools/upload_to_google_storage.py --bucket ' | |
59 '<Your pageset\'s bucket> %s.\nFor more info: see ' | |
60 'http://www.chromium.org/developers/telemetry/' | |
61 'record_a_page_set#TOC-Upload-the-recording-to-Cloud-Storage' % | |
62 (filename, wpr_filename))) | |
63 return results | |
64 | |
65 | |
39 def _CheckJson(input_api, output_api): | 66 def _CheckJson(input_api, output_api): |
40 """Checks whether JSON files in this change can be parsed.""" | 67 """Checks whether JSON files in this change can be parsed.""" |
41 for affected_file in input_api.AffectedFiles(include_deletes=False): | 68 for affected_file in input_api.AffectedFiles(include_deletes=False): |
42 filename = affected_file.AbsoluteLocalPath() | 69 filename = affected_file.AbsoluteLocalPath() |
43 if os.path.splitext(filename)[1] != '.json': | 70 if os.path.splitext(filename)[1] != '.json': |
44 continue | 71 continue |
45 try: | 72 try: |
46 input_api.json.load(open(filename)) | 73 input_api.json.load(open(filename)) |
47 except ValueError: | 74 except ValueError: |
48 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)] | 75 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)] |
49 return [] | 76 return [] |
50 | 77 |
51 | 78 |
52 def CheckChangeOnUpload(input_api, output_api): | 79 def CheckChangeOnUpload(input_api, output_api): |
53 report = [] | 80 report = [] |
54 report.extend(_CommonChecks(input_api, output_api)) | 81 report.extend(_CommonChecks(input_api, output_api)) |
55 return report | 82 return report |
56 | 83 |
57 | 84 |
58 def CheckChangeOnCommit(input_api, output_api): | 85 def CheckChangeOnCommit(input_api, output_api): |
59 report = [] | 86 report = [] |
60 report.extend(_CommonChecks(input_api, output_api)) | 87 report.extend(_CommonChecks(input_api, output_api)) |
61 return report | 88 return report |
OLD | NEW |