| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 os | 5 import os |
| 6 import re | 6 import re |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 from . import parse_metric | 9 from . import parse_metric |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 # and chart names. | 175 # and chart names. |
| 176 if Metric.OLD_STYLE_DELIMITER not in metric.chart_name: | 176 if Metric.OLD_STYLE_DELIMITER not in metric.chart_name: |
| 177 return False, [] # Give up; no results found. | 177 return False, [] # Give up; no results found. |
| 178 interaction, chart = metric.chart_name.split(Metric.OLD_STYLE_DELIMITER, 1) | 178 interaction, chart = metric.chart_name.split(Metric.OLD_STYLE_DELIMITER, 1) |
| 179 metric.interaction_record_name = interaction | 179 metric.interaction_record_name = interaction |
| 180 metric.chart_name = chart | 180 metric.chart_name = chart |
| 181 has_valid_value, value, _ = parse_metric.parse_chartjson_metric( | 181 has_valid_value, value, _ = parse_metric.parse_chartjson_metric( |
| 182 results, metric.as_pair()) | 182 results, metric.as_pair()) |
| 183 return has_valid_value, value | 183 return has_valid_value, value |
| 184 | 184 |
| 185 def _rebase_path(file_path): |
| 186 """Attempts to make a path relative src/out/Release""" |
| 187 if file_path.startswith('src/tools') or file_path.startswith(r'src\tools'): |
| 188 return os.path.join(os.pardir, os.pardir, os.pardir, file_path) |
| 189 return file_path |
| 185 | 190 |
| 186 def _run_command(api, command, step_name): | 191 def _run_command(api, command, step_name): |
| 187 # TODO(robertocn): Reevaluate this approach when adding support for non-perf | |
| 188 # tests and non-linux platforms. | |
| 189 if api.m.platform.is_linux and 'xvfb' not in command: | |
| 190 command = 'xvfb-run -a ' + command | |
| 191 command_parts = command.split() | 192 command_parts = command.split() |
| 192 stdout = api.m.raw_io.output() | 193 stdout = api.m.raw_io.output() |
| 193 stderr = api.m.raw_io.output() | 194 stderr = api.m.raw_io.output() |
| 194 | 195 |
| 195 # TODO(prasadv): Remove this once bisect runs are no longer running | 196 # TODO(prasadv): Remove this once bisect runs are no longer running |
| 196 # against revisions from February 2016 or earlier. | 197 # against revisions from February 2016 or earlier. |
| 197 kwargs = {} | 198 kwargs = {} |
| 198 if 'android-chrome' in command: # pragma: no cover | 199 if 'android-chrome' in command: # pragma: no cover |
| 199 kwargs['env'] = {'CHROMIUM_OUTPUT_DIR': api.m.chromium.output_dir} | 200 kwargs['env'] = {'CHROMIUM_OUTPUT_DIR': api.m.chromium.output_dir} |
| 200 | 201 |
| 201 try: | 202 try: |
| 202 step_result = api.m.step( | 203 step_result = api.m.chromium.runtest( |
| 203 step_name, | 204 test=_rebase_path(command_parts[0]), |
| 204 command_parts, | 205 args=command_parts[1:], |
| 206 xvfb=True, |
| 207 name=step_name, |
| 205 stdout=stdout, | 208 stdout=stdout, |
| 206 stderr=stderr, | 209 stderr=stderr, |
| 207 **kwargs) | 210 **kwargs) |
| 208 step_result.presentation.logs['Captured Output'] = ( | 211 step_result.presentation.logs['Captured Output'] = ( |
| 209 step_result.stdout or '').splitlines() | 212 step_result.stdout or '').splitlines() |
| 210 except api.m.step.StepFailure as sf: | 213 except api.m.step.StepFailure as sf: |
| 211 sf.result.presentation.logs['Failure Output'] = ( | 214 sf.result.presentation.logs['Failure Output'] = ( |
| 212 sf.result.stdout or '').splitlines() | 215 sf.result.stdout or '').splitlines() |
| 213 if sf.result.stderr: # pragma: no cover | 216 if sf.result.stderr: # pragma: no cover |
| 214 sf.result.presentation.logs['stderr'] = ( | 217 sf.result.presentation.logs['stderr'] = ( |
| 215 sf.result.stderr).splitlines() | 218 sf.result.stderr).splitlines() |
| 216 return sf.result.stdout, sf.result.stderr, sf.result.retcode | 219 return sf.result.stdout, sf.result.stderr, sf.result.retcode |
| 217 return step_result.stdout, step_result.stderr, step_result.retcode | 220 return step_result.stdout, step_result.stderr, step_result.retcode |
| OLD | NEW |