OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import logging | 5 import logging |
6 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import shutil | 8 import shutil |
9 import sys | 9 import sys |
10 import zipfile | 10 import zipfile |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 us = self.CreateUserStorySet(finder_options) | 168 us = self.CreateUserStorySet(finder_options) |
169 if isinstance(pt, page_test.PageTest): | 169 if isinstance(pt, page_test.PageTest): |
170 if any(not isinstance(p, page.Page) for p in us.user_stories): | 170 if any(not isinstance(p, page.Page) for p in us.user_stories): |
171 raise Exception( | 171 raise Exception( |
172 'PageTest must be used with UserStorySet containing only ' | 172 'PageTest must be used with UserStorySet containing only ' |
173 'telemetry.page.Page user stories.') | 173 'telemetry.page.Page user stories.') |
174 | 174 |
175 self._DownloadGeneratedProfileArchive(finder_options) | 175 self._DownloadGeneratedProfileArchive(finder_options) |
176 | 176 |
177 benchmark_metadata = self.GetMetadata() | 177 benchmark_metadata = self.GetMetadata() |
178 results = results_options.CreateResults(benchmark_metadata, finder_options) | 178 with results_options.CreateResults(benchmark_metadata, |
179 try: | 179 finder_options) as results: |
180 user_story_runner.Run(pt, us, expectations, finder_options, results, | 180 try: |
181 max_failures=self._max_failures) | 181 user_story_runner.Run(pt, us, expectations, finder_options, results, |
182 return_code = min(254, len(results.failures)) | 182 max_failures=self._max_failures) |
183 except Exception: | 183 return_code = min(254, len(results.failures)) |
184 exception_formatter.PrintFormattedException() | 184 except Exception: |
185 return_code = 255 | 185 exception_formatter.PrintFormattedException() |
| 186 return_code = 255 |
186 | 187 |
187 bucket = cloud_storage.BUCKET_ALIASES[finder_options.upload_bucket] | 188 bucket = cloud_storage.BUCKET_ALIASES[finder_options.upload_bucket] |
188 if finder_options.upload_results: | 189 if finder_options.upload_results: |
189 results.UploadTraceFilesToCloud(bucket) | 190 results.UploadTraceFilesToCloud(bucket) |
190 results.UploadProfilingFilesToCloud(bucket) | 191 results.UploadProfilingFilesToCloud(bucket) |
191 | 192 |
192 results.PrintSummary() | 193 results.PrintSummary() |
193 return return_code | 194 return return_code |
194 | 195 |
195 def _DownloadGeneratedProfileArchive(self, options): | 196 def _DownloadGeneratedProfileArchive(self, options): |
196 """Download and extract profile directory archive if one exists.""" | 197 """Download and extract profile directory archive if one exists.""" |
197 archive_name = getattr(self, 'generated_profile_archive', None) | 198 archive_name = getattr(self, 'generated_profile_archive', None) |
198 | 199 |
199 # If attribute not specified, nothing to do. | 200 # If attribute not specified, nothing to do. |
200 if not archive_name: | 201 if not archive_name: |
201 return | 202 return |
202 | 203 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 """ | 317 """ |
317 return test_expectations.TestExpectations() | 318 return test_expectations.TestExpectations() |
318 | 319 |
319 | 320 |
320 def AddCommandLineArgs(parser): | 321 def AddCommandLineArgs(parser): |
321 user_story_runner.AddCommandLineArgs(parser) | 322 user_story_runner.AddCommandLineArgs(parser) |
322 | 323 |
323 | 324 |
324 def ProcessCommandLineArgs(parser, args): | 325 def ProcessCommandLineArgs(parser, args): |
325 user_story_runner.ProcessCommandLineArgs(parser, args) | 326 user_story_runner.ProcessCommandLineArgs(parser, args) |
OLD | NEW |