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

Side by Side Diff: build/android/pylib/gtest/test_runner.py

Issue 719753005: Add duration to gtest test results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made regex still match if test duration not present. Created 6 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 8
9 from pylib import pexpect 9 from pylib import pexpect
10 from pylib.base import base_test_result 10 from pylib.base import base_test_result
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Args: 63 Args:
64 p: An instance of pexpect spawn class. 64 p: An instance of pexpect spawn class.
65 65
66 Returns: 66 Returns:
67 A TestRunResults object. 67 A TestRunResults object.
68 """ 68 """
69 results = base_test_result.TestRunResults() 69 results = base_test_result.TestRunResults()
70 70
71 # Test case statuses. 71 # Test case statuses.
72 re_run = re.compile('\[ RUN \] ?(.*)\r\n') 72 re_run = re.compile('\[ RUN \] ?(.*)\r\n')
73 re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') 73 re_fail = re.compile('\[ FAILED \] ?(.*?)( \((.*) ms\))?\r\r\n')
jbudorick 2014/11/14 01:50:24 Narrow the second capture a little. What do you ex
74 re_ok = re.compile('\[ OK \] ?(.*?) .*\r\n') 74 re_ok = re.compile('\[ OK \] ?(.*?)( \((.*) ms\))?\r\r\n')
75 75
76 # Test run statuses. 76 # Test run statuses.
77 re_passed = re.compile('\[ PASSED \] ?(.*)\r\n') 77 re_passed = re.compile('\[ PASSED \] ?(.*)\r\n')
78 re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') 78 re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n')
79 # Signal handlers are installed before starting tests 79 # Signal handlers are installed before starting tests
80 # to output the CRASHED marker when a crash happens. 80 # to output the CRASHED marker when a crash happens.
81 re_crash = re.compile('\[ CRASHED \](.*)\r\n') 81 re_crash = re.compile('\[ CRASHED \](.*)\r\n')
82 82
83 log = '' 83 log = ''
84 try: 84 try:
85 while True: 85 while True:
86 full_test_name = None 86 full_test_name = None
87
87 found = p.expect([re_run, re_passed, re_runner_fail], 88 found = p.expect([re_run, re_passed, re_runner_fail],
88 timeout=self._timeout) 89 timeout=self._timeout)
89 if found == 1: # re_passed 90 if found == 1: # re_passed
90 break 91 break
91 elif found == 2: # re_runner_fail 92 elif found == 2: # re_runner_fail
92 break 93 break
93 else: # re_run 94 else: # re_run
94 full_test_name = p.match.group(1).replace('\r', '') 95 full_test_name = p.match.group(1).replace('\r', '')
95 found = p.expect([re_ok, re_fail, re_crash], timeout=self._timeout) 96 found = p.expect([re_ok, re_fail, re_crash], timeout=self._timeout)
96 log = p.before.replace('\r', '') 97 log = p.before.replace('\r', '')
97 if found == 0: # re_ok 98 if found == 0: # re_ok
98 if full_test_name == p.match.group(1).replace('\r', ''): 99 if full_test_name == p.match.group(1).replace('\r', ''):
100 duration_ms = int(p.match.group(3)) if p.match.group(3) else 0
99 results.AddResult(base_test_result.BaseTestResult( 101 results.AddResult(base_test_result.BaseTestResult(
100 full_test_name, base_test_result.ResultType.PASS, 102 full_test_name, base_test_result.ResultType.PASS,
101 log=log)) 103 duration=duration_ms, log=log))
102 elif found == 2: # re_crash 104 elif found == 2: # re_crash
103 results.AddResult(base_test_result.BaseTestResult( 105 results.AddResult(base_test_result.BaseTestResult(
104 full_test_name, base_test_result.ResultType.CRASH, 106 full_test_name, base_test_result.ResultType.CRASH,
105 log=log)) 107 log=log))
106 break 108 break
107 else: # re_fail 109 else: # re_fail
110 duration_ms = int(p.match.group(3)) if p.match.group(3) else 0
108 results.AddResult(base_test_result.BaseTestResult( 111 results.AddResult(base_test_result.BaseTestResult(
109 full_test_name, base_test_result.ResultType.FAIL, log=log)) 112 full_test_name, base_test_result.ResultType.FAIL,
113 duration=duration_ms, log=log))
110 except pexpect.EOF: 114 except pexpect.EOF:
111 logging.error('Test terminated - EOF') 115 logging.error('Test terminated - EOF')
112 # We're here because either the device went offline, or the test harness 116 # We're here because either the device went offline, or the test harness
113 # crashed without outputting the CRASHED marker (crbug.com/175538). 117 # crashed without outputting the CRASHED marker (crbug.com/175538).
114 if not self.device.IsOnline(): 118 if not self.device.IsOnline():
115 raise device_errors.DeviceUnreachableError( 119 raise device_errors.DeviceUnreachableError(
116 'Device %s went offline.' % str(self.device)) 120 'Device %s went offline.' % str(self.device))
117 if full_test_name: 121 if full_test_name:
118 results.AddResult(base_test_result.BaseTestResult( 122 results.AddResult(base_test_result.BaseTestResult(
119 full_test_name, base_test_result.ResultType.CRASH, 123 full_test_name, base_test_result.ResultType.CRASH,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 self.tool.SetupEnvironment() 175 self.tool.SetupEnvironment()
172 176
173 #override 177 #override
174 def TearDown(self): 178 def TearDown(self):
175 """Cleans up the test enviroment for the test suite.""" 179 """Cleans up the test enviroment for the test suite."""
176 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 180 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
177 self._perf_controller.SetDefaultPerfMode() 181 self._perf_controller.SetDefaultPerfMode()
178 self.test_package.ClearApplicationState(self.device) 182 self.test_package.ClearApplicationState(self.device)
179 self.tool.CleanUpEnvironment() 183 self.tool.CleanUpEnvironment()
180 super(TestRunner, self).TearDown() 184 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698