Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: build/android/pylib/utils/report_results.py

Issue 757683002: [Android] Implement generic JSON results that match base/test/launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit issue Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/utils/json_results_generator.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Module containing utility functions for reporting results."""
6
7 import logging
8 import os
9 import re
10
11 from pylib import constants
12 from pylib.utils import flakiness_dashboard_results_uploader
13
14
15 def _LogToFile(results, test_type, suite_name):
16 """Log results to local files which can be used for aggregation later."""
17 log_file_path = os.path.join(constants.GetOutDirectory(), 'test_logs')
18 if not os.path.exists(log_file_path):
19 os.mkdir(log_file_path)
20 full_file_name = os.path.join(
21 log_file_path, re.sub(r'\W', '_', test_type).lower() + '.log')
22 if not os.path.exists(full_file_name):
23 with open(full_file_name, 'w') as log_file:
24 print >> log_file, '\n%s results for %s build %s:' % (
25 test_type, os.environ.get('BUILDBOT_BUILDERNAME'),
26 os.environ.get('BUILDBOT_BUILDNUMBER'))
27 logging.info('Writing results to %s.' % full_file_name)
28
29 logging.info('Writing results to %s.' % full_file_name)
30 with open(full_file_name, 'a') as log_file:
31 shortened_suite_name = suite_name[:25] + (suite_name[25:] and '...')
32 print >> log_file, '%s%s' % (shortened_suite_name.ljust(30),
33 results.GetShortForm())
34
35
36 def _LogToFlakinessDashboard(results, test_type, test_package,
37 flakiness_server):
38 """Upload results to the flakiness dashboard"""
39 logging.info('Upload results for test type "%s", test package "%s" to %s' %
40 (test_type, test_package, flakiness_server))
41
42 try:
43 if test_type == 'Instrumentation':
44 if flakiness_server == constants.UPSTREAM_FLAKINESS_SERVER:
45 assert test_package in ['ContentShellTest',
46 'ChromeShellTest',
47 'AndroidWebViewTest']
48 dashboard_test_type = ('%s_instrumentation_tests' %
49 test_package.lower().rstrip('test'))
50 # Downstream server.
51 else:
52 dashboard_test_type = 'Chromium_Android_Instrumentation'
53
54 elif test_type == 'Unit test':
55 dashboard_test_type = test_package
56
57 else:
58 logging.warning('Invalid test type')
59 return
60
61 flakiness_dashboard_results_uploader.Upload(
62 results, flakiness_server, dashboard_test_type)
63
64 except Exception as e:
65 logging.error(e)
66
67
68 def LogFull(results, test_type, test_package, annotation=None,
69 flakiness_server=None):
70 """Log the tests results for the test suite.
71
72 The results will be logged three different ways:
73 1. Log to stdout.
74 2. Log to local files for aggregating multiple test steps
75 (on buildbots only).
76 3. Log to flakiness dashboard (on buildbots only).
77
78 Args:
79 results: An instance of TestRunResults object.
80 test_type: Type of the test (e.g. 'Instrumentation', 'Unit test', etc.).
81 test_package: Test package name (e.g. 'ipc_tests' for gtests,
82 'ContentShellTest' for instrumentation tests)
83 annotation: If instrumenation test type, this is a list of annotations
84 (e.g. ['Smoke', 'SmallTest']).
85 flakiness_server: If provider, upload the results to flakiness dashboard
86 with this URL.
87 """
88 if not results.DidRunPass():
89 logging.critical('*' * 80)
90 logging.critical('Detailed Logs')
91 logging.critical('*' * 80)
92 for line in results.GetLogs().splitlines():
93 logging.critical(line)
94 logging.critical('*' * 80)
95 logging.critical('Summary')
96 logging.critical('*' * 80)
97 for line in results.GetGtestForm().splitlines():
98 logging.critical(line)
99 logging.critical('*' * 80)
100
101 if os.environ.get('BUILDBOT_BUILDERNAME'):
102 # It is possible to have multiple buildbot steps for the same
103 # instrumenation test package using different annotations.
104 if annotation and len(annotation) == 1:
105 suite_name = annotation[0]
106 else:
107 suite_name = test_package
108 _LogToFile(results, test_type, suite_name)
109
110 if flakiness_server:
111 _LogToFlakinessDashboard(results, test_type, test_package,
112 flakiness_server)
OLDNEW
« no previous file with comments | « build/android/pylib/utils/json_results_generator.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698