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 from pylib.utils import flakiness_dashboard_results_uploader | 12 from pylib.results.flakiness_dashboard import results_uploader |
13 | 13 |
14 | 14 |
15 def _LogToFile(results, test_type, suite_name): | 15 def _LogToFile(results, test_type, suite_name): |
16 """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.""" |
17 log_file_path = os.path.join(constants.GetOutDirectory(), 'test_logs') | 17 log_file_path = os.path.join(constants.GetOutDirectory(), 'test_logs') |
18 if not os.path.exists(log_file_path): | 18 if not os.path.exists(log_file_path): |
19 os.mkdir(log_file_path) | 19 os.mkdir(log_file_path) |
20 full_file_name = os.path.join( | 20 full_file_name = os.path.join( |
21 log_file_path, re.sub(r'\W', '_', test_type).lower() + '.log') | 21 log_file_path, re.sub(r'\W', '_', test_type).lower() + '.log') |
22 if not os.path.exists(full_file_name): | 22 if not os.path.exists(full_file_name): |
(...skipping 28 matching lines...) Expand all Loading... |
51 else: | 51 else: |
52 dashboard_test_type = 'Chromium_Android_Instrumentation' | 52 dashboard_test_type = 'Chromium_Android_Instrumentation' |
53 | 53 |
54 elif test_type == 'Unit test': | 54 elif test_type == 'Unit test': |
55 dashboard_test_type = test_package | 55 dashboard_test_type = test_package |
56 | 56 |
57 else: | 57 else: |
58 logging.warning('Invalid test type') | 58 logging.warning('Invalid test type') |
59 return | 59 return |
60 | 60 |
61 flakiness_dashboard_results_uploader.Upload( | 61 results_uploader.Upload( |
62 results, flakiness_server, dashboard_test_type) | 62 results, flakiness_server, dashboard_test_type) |
63 | 63 |
64 except Exception as e: | 64 except Exception as e: |
65 logging.error(e) | 65 logging.error(e) |
66 | 66 |
67 | 67 |
68 def LogFull(results, test_type, test_package, annotation=None, | 68 def LogFull(results, test_type, test_package, annotation=None, |
69 flakiness_server=None): | 69 flakiness_server=None): |
70 """Log the tests results for the test suite. | 70 """Log the tests results for the test suite. |
71 | 71 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 # instrumenation test package using different annotations. | 103 # instrumenation test package using different annotations. |
104 if annotation and len(annotation) == 1: | 104 if annotation and len(annotation) == 1: |
105 suite_name = annotation[0] | 105 suite_name = annotation[0] |
106 else: | 106 else: |
107 suite_name = test_package | 107 suite_name = test_package |
108 _LogToFile(results, test_type, suite_name) | 108 _LogToFile(results, test_type, suite_name) |
109 | 109 |
110 if flakiness_server: | 110 if flakiness_server: |
111 _LogToFlakinessDashboard(results, test_type, test_package, | 111 _LogToFlakinessDashboard(results, test_type, test_package, |
112 flakiness_server) | 112 flakiness_server) |
OLD | NEW |