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

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

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 months 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/results/json_results_test.py ('k') | build/android/pylib/screenshot.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.results.flakiness_dashboard import 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 'ChromePublicTest',
47 'ChromeShellTest',
48 'ChromeSyncShellTest',
49 'AndroidWebViewTest']
50 dashboard_test_type = ('%s_instrumentation_tests' %
51 test_package.lower().rstrip('test'))
52 # Downstream server.
53 else:
54 dashboard_test_type = 'Chromium_Android_Instrumentation'
55
56 elif test_type == 'Unit test':
57 dashboard_test_type = test_package
58
59 else:
60 logging.warning('Invalid test type')
61 return
62
63 results_uploader.Upload(
64 results, flakiness_server, dashboard_test_type)
65
66 except Exception as e:
67 logging.error(e)
68
69
70 def LogFull(results, test_type, test_package, annotation=None,
71 flakiness_server=None):
72 """Log the tests results for the test suite.
73
74 The results will be logged three different ways:
75 1. Log to stdout.
76 2. Log to local files for aggregating multiple test steps
77 (on buildbots only).
78 3. Log to flakiness dashboard (on buildbots only).
79
80 Args:
81 results: An instance of TestRunResults object.
82 test_type: Type of the test (e.g. 'Instrumentation', 'Unit test', etc.).
83 test_package: Test package name (e.g. 'ipc_tests' for gtests,
84 'ContentShellTest' for instrumentation tests)
85 annotation: If instrumenation test type, this is a list of annotations
86 (e.g. ['Smoke', 'SmallTest']).
87 flakiness_server: If provider, upload the results to flakiness dashboard
88 with this URL.
89 """
90 if not results.DidRunPass():
91 logging.critical('*' * 80)
92 logging.critical('Detailed Logs')
93 logging.critical('*' * 80)
94 for line in results.GetLogs().splitlines():
95 logging.critical(line)
96 logging.critical('*' * 80)
97 logging.critical('Summary')
98 logging.critical('*' * 80)
99 for line in results.GetGtestForm().splitlines():
100 logging.critical(line)
101 logging.critical('*' * 80)
102
103 if os.environ.get('BUILDBOT_BUILDERNAME'):
104 # It is possible to have multiple buildbot steps for the same
105 # instrumenation test package using different annotations.
106 if annotation and len(annotation) == 1:
107 suite_name = annotation[0]
108 else:
109 suite_name = test_package
110 _LogToFile(results, test_type, suite_name)
111
112 if flakiness_server:
113 _LogToFlakinessDashboard(results, test_type, test_package,
114 flakiness_server)
OLDNEW
« no previous file with comments | « build/android/pylib/results/json_results_test.py ('k') | build/android/pylib/screenshot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698