| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 """Module containing utility functions for reporting results.""" | 5 """Module containing utility functions for reporting results.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 | 10 |
| 11 from pylib import constants | 11 from pylib import constants |
| 12 | 12 from pylib.utils import flakiness_dashboard_results_uploader |
| 13 import flakiness_dashboard_results_uploader | |
| 14 | 13 |
| 15 | 14 |
| 16 def _LogToFile(results, test_type, suite_name): | 15 def _LogToFile(results, test_type, suite_name): |
| 17 """Log results to local files which can be used for aggregation later.""" | 16 """Log results to local files which can be used for aggregation later.""" |
| 18 log_file_path = os.path.join(constants.GetOutDirectory(), 'test_logs') | 17 log_file_path = os.path.join(constants.GetOutDirectory(), 'test_logs') |
| 19 if not os.path.exists(log_file_path): | 18 if not os.path.exists(log_file_path): |
| 20 os.mkdir(log_file_path) | 19 os.mkdir(log_file_path) |
| 21 full_file_name = os.path.join( | 20 full_file_name = os.path.join( |
| 22 log_file_path, re.sub('\W', '_', test_type).lower() + '.log') | 21 log_file_path, re.sub('\W', '_', test_type).lower() + '.log') |
| 23 if not os.path.exists(full_file_name): | 22 if not os.path.exists(full_file_name): |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 logging.info('Upload results for test type "%s", test package "%s" to %s' % | 39 logging.info('Upload results for test type "%s", test package "%s" to %s' % |
| 41 (test_type, test_package, flakiness_server)) | 40 (test_type, test_package, flakiness_server)) |
| 42 | 41 |
| 43 # TODO(frankf): Enable uploading for gtests. | 42 # TODO(frankf): Enable uploading for gtests. |
| 44 if test_type != 'Instrumentation': | 43 if test_type != 'Instrumentation': |
| 45 logging.warning('Invalid test type.') | 44 logging.warning('Invalid test type.') |
| 46 return | 45 return |
| 47 | 46 |
| 48 try: | 47 try: |
| 49 if flakiness_server == constants.UPSTREAM_FLAKINESS_SERVER: | 48 if flakiness_server == constants.UPSTREAM_FLAKINESS_SERVER: |
| 50 assert test_package in ['ContentShellTest', | 49 assert test_package in ['ContentShellTest', |
| 51 'ChromiumTestShellTest', | 50 'ChromiumTestShellTest', |
| 52 'AndroidWebViewTest'] | 51 'AndroidWebViewTest'] |
| 53 dashboard_test_type = ('%s_instrumentation_tests' % | 52 dashboard_test_type = ('%s_instrumentation_tests' % |
| 54 test_package.lower().rstrip('test')) | 53 test_package.lower().rstrip('test')) |
| 55 # Downstream server. | 54 # Downstream server. |
| 56 else: | 55 else: |
| 57 dashboard_test_type = 'Chromium_Android_Instrumentation' | 56 dashboard_test_type = 'Chromium_Android_Instrumentation' |
| 58 | 57 |
| 59 flakiness_dashboard_results_uploader.Upload( | 58 flakiness_dashboard_results_uploader.Upload( |
| 60 results, flakiness_server, dashboard_test_type) | 59 results, flakiness_server, dashboard_test_type) |
| 61 except Exception as e: | 60 except Exception as e: |
| 62 logging.error(e) | 61 logging.error(e) |
| 63 | 62 |
| 64 | 63 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 # instrumenation test package using different annotations. | 99 # instrumenation test package using different annotations. |
| 101 if annotation and len(annotation) == 1: | 100 if annotation and len(annotation) == 1: |
| 102 suite_name = annotation[0] | 101 suite_name = annotation[0] |
| 103 else: | 102 else: |
| 104 suite_name = test_package | 103 suite_name = test_package |
| 105 _LogToFile(results, test_type, suite_name) | 104 _LogToFile(results, test_type, suite_name) |
| 106 | 105 |
| 107 if flakiness_server: | 106 if flakiness_server: |
| 108 _LogToFlakinessDashboard(results, test_type, test_package, | 107 _LogToFlakinessDashboard(results, test_type, test_package, |
| 109 flakiness_server) | 108 flakiness_server) |
| OLD | NEW |