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 sys | 8 import sys |
9 import time | 9 import time |
10 | 10 |
11 import py_utils | 11 import py_utils |
12 from py_utils import cloud_storage # pylint: disable=import-error | 12 from py_utils import cloud_storage # pylint: disable=import-error |
13 | 13 |
14 from telemetry.core import exceptions | 14 from telemetry.core import exceptions |
15 from telemetry import decorators | 15 from telemetry import decorators |
16 from telemetry.internal.actions import page_action | 16 from telemetry.internal.actions import page_action |
17 from telemetry.internal.browser import browser_finder | 17 from telemetry.internal.browser import browser_finder |
18 from telemetry.internal.results import results_options | 18 from telemetry.internal.results import results_options |
19 from telemetry.internal.util import exception_formatter | 19 from telemetry.internal.util import exception_formatter |
| 20 from telemetry.internal.util import log_stream |
20 from telemetry import page | 21 from telemetry import page |
21 from telemetry.page import legacy_page_test | 22 from telemetry.page import legacy_page_test |
22 from telemetry import story as story_module | 23 from telemetry import story as story_module |
23 from telemetry.util import wpr_modes | 24 from telemetry.util import wpr_modes |
24 from telemetry.value import failure | 25 from telemetry.value import failure |
25 from telemetry.value import skip | 26 from telemetry.value import skip |
26 from telemetry.value import scalar | 27 from telemetry.value import scalar |
27 from telemetry.web_perf import story_test | 28 from telemetry.web_perf import story_test |
28 from tracing.value import histogram | 29 from tracing.value import histogram |
29 from tracing.value.diagnostics import reserved_infos | 30 from tracing.value.diagnostics import reserved_infos |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 def _GenerateTagMapFromStorySet(stories): | 82 def _GenerateTagMapFromStorySet(stories): |
82 tagmap = histogram.TagMap({}) | 83 tagmap = histogram.TagMap({}) |
83 for s in stories: | 84 for s in stories: |
84 for t in s.tags: | 85 for t in s.tags: |
85 tagmap.AddTagAndStoryDisplayName(t, s.name) | 86 tagmap.AddTagAndStoryDisplayName(t, s.name) |
86 return tagmap | 87 return tagmap |
87 | 88 |
88 | 89 |
89 def _RunStoryAndProcessErrorIfNeeded(story, results, state, test): | 90 def _RunStoryAndProcessErrorIfNeeded(story, results, state, test): |
90 def ProcessError(description=None): | 91 def ProcessError(description=None): |
| 92 # Flush all the existing log upon failure. |
| 93 log_stream.FlushLogStream(sys.stdout) |
| 94 |
91 state.DumpStateUponFailure(story, results) | 95 state.DumpStateUponFailure(story, results) |
92 # Note: adding the FailureValue to the results object also normally | 96 # Note: adding the FailureValue to the results object also normally |
93 # cause the progress_reporter to log it in the output. | 97 # cause the progress_reporter to log it in the output. |
94 results.AddValue(failure.FailureValue(story, sys.exc_info(), description)) | 98 results.AddValue(failure.FailureValue(story, sys.exc_info(), description)) |
95 try: | 99 try: |
96 if isinstance(test, story_test.StoryTest): | 100 if isinstance(test, story_test.StoryTest): |
97 test.WillRunStory(state.platform) | 101 test.WillRunStory(state.platform) |
98 state.WillRunStory(story) | 102 state.WillRunStory(story) |
99 if not state.CanRunStory(story): | 103 if not state.CanRunStory(story): |
100 results.AddValue(skip.SkipValue( | 104 results.AddValue(skip.SkipValue( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 # Effective max failures gives priority to command-line flag value. | 176 # Effective max failures gives priority to command-line flag value. |
173 effective_max_failures = finder_options.max_failures | 177 effective_max_failures = finder_options.max_failures |
174 if effective_max_failures is None: | 178 if effective_max_failures is None: |
175 effective_max_failures = max_failures | 179 effective_max_failures = max_failures |
176 | 180 |
177 state = None | 181 state = None |
178 device_info_diags = {} | 182 device_info_diags = {} |
179 try: | 183 try: |
180 for storyset_repeat_counter in xrange(finder_options.pageset_repeat): | 184 for storyset_repeat_counter in xrange(finder_options.pageset_repeat): |
181 for story in stories: | 185 for story in stories: |
| 186 log_stream.TruncateLogStream() |
182 if not state: | 187 if not state: |
183 # Construct shared state by using a copy of finder_options. Shared | 188 # Construct shared state by using a copy of finder_options. Shared |
184 # state may update the finder_options. If we tear down the shared | 189 # state may update the finder_options. If we tear down the shared |
185 # state after this story run, we want to construct the shared | 190 # state after this story run, we want to construct the shared |
186 # state for the next story from the original finder_options. | 191 # state for the next story from the original finder_options. |
187 state = story_set.shared_state_class( | 192 state = story_set.shared_state_class( |
188 test, finder_options.Copy(), story_set) | 193 test, finder_options.Copy(), story_set) |
189 | 194 |
190 results.WillRunPage(story, storyset_repeat_counter) | 195 results.WillRunPage(story, storyset_repeat_counter) |
191 | 196 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 reserved_infos.OS_VERSIONS.name: state.platform.GetOSVersionName(), | 463 reserved_infos.OS_VERSIONS.name: state.platform.GetOSVersionName(), |
459 } | 464 } |
460 | 465 |
461 device_info_diangostics = {} | 466 device_info_diangostics = {} |
462 | 467 |
463 for name, value in device_info_data.iteritems(): | 468 for name, value in device_info_data.iteritems(): |
464 if not value: | 469 if not value: |
465 continue | 470 continue |
466 device_info_diangostics[name] = histogram.GenericSet([value]) | 471 device_info_diangostics[name] = histogram.GenericSet([value]) |
467 return device_info_diangostics | 472 return device_info_diangostics |
OLD | NEW |