Chromium Code Reviews| 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 |
| 38 | |
| 39 | |
| 40 def _CheckWprShaFiles(input_api, output_api): | |
| 41 """Check whether the wpr sha files have matching URLs.""" | |
| 42 results = [] | |
| 43 old_sys_path = sys.path | |
|
aiolos (Not reviewing)
2015/02/24 19:37:49
The nested sys.path changes are unneeded. Either t
nednguyen
2015/02/24 20:57:46
Err, I didn't look at this carefully and thought t
| |
| 44 try: | |
| 45 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path | |
| 46 from telemetry.util import cloud_storage | |
| 47 for affected_file in input_api.AffectedFiles(include_deletes=False): | |
| 48 filename = affected_file.AbsoluteLocalPath() | |
| 49 if not filename.endswith('wpr.sha1'): | |
| 50 continue | |
| 51 is_wpr_file_uploaded = False | |
| 52 expected_hash = cloud_storage.ReadHash(filename) | |
| 53 is_wpr_file_uploaded = any( | |
| 54 cloud_storage.Exists(bucket, expected_hash) | |
| 55 for bucket in cloud_storage.BUCKET_ALIASES.itervalues()) | |
| 56 if not is_wpr_file_uploaded: | |
| 57 wpr_filename = filename[:-5] | |
| 58 results.append(output_api.PresubmitError( | |
| 59 'There is no URLs matched for wpr sha file %s.\n' | |
| 60 'You can upload your new wpr archive file with the command:\n' | |
| 61 'depot_tools/upload_to_google_storage.py --bucket ' | |
| 62 '<Your pageset\'s bucket> %s.\nFor more info: see ' | |
| 63 'http://www.chromium.org/developers/telemetry/' | |
| 64 'record_a_page_set#TOC-Upload-the-recording-to-Cloud-Storage' % | |
| 65 (filename, wpr_filename))) | |
| 66 finally: | |
| 67 sys.path = old_sys_path | |
| 68 return results | |
| 37 | 69 |
| 38 | 70 |
| 39 def _CheckJson(input_api, output_api): | 71 def _CheckJson(input_api, output_api): |
| 40 """Checks whether JSON files in this change can be parsed.""" | 72 """Checks whether JSON files in this change can be parsed.""" |
| 41 for affected_file in input_api.AffectedFiles(include_deletes=False): | 73 for affected_file in input_api.AffectedFiles(include_deletes=False): |
| 42 filename = affected_file.AbsoluteLocalPath() | 74 filename = affected_file.AbsoluteLocalPath() |
| 43 if os.path.splitext(filename)[1] != '.json': | 75 if os.path.splitext(filename)[1] != '.json': |
| 44 continue | 76 continue |
| 45 try: | 77 try: |
| 46 input_api.json.load(open(filename)) | 78 input_api.json.load(open(filename)) |
| 47 except ValueError: | 79 except ValueError: |
| 48 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)] | 80 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)] |
| 49 return [] | 81 return [] |
| 50 | 82 |
| 51 | 83 |
| 52 def CheckChangeOnUpload(input_api, output_api): | 84 def CheckChangeOnUpload(input_api, output_api): |
| 53 report = [] | 85 report = [] |
| 54 report.extend(_CommonChecks(input_api, output_api)) | 86 report.extend(_CommonChecks(input_api, output_api)) |
| 55 return report | 87 return report |
| 56 | 88 |
| 57 | 89 |
| 58 def CheckChangeOnCommit(input_api, output_api): | 90 def CheckChangeOnCommit(input_api, output_api): |
| 59 report = [] | 91 report = [] |
| 60 report.extend(_CommonChecks(input_api, output_api)) | 92 report.extend(_CommonChecks(input_api, output_api)) |
| 61 return report | 93 return report |
| OLD | NEW |