OLD | NEW |
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 | 5 |
6 import logging | 6 import logging |
7 import re | 7 import re |
8 import os | 8 import os |
9 import pexpect | 9 import pexpect |
10 | 10 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 def _WatchTestOutput(self, p): | 125 def _WatchTestOutput(self, p): |
126 """Watches the test output. | 126 """Watches the test output. |
127 Args: | 127 Args: |
128 p: the process generating output as created by pexpect.spawn. | 128 p: the process generating output as created by pexpect.spawn. |
129 """ | 129 """ |
130 ok_tests = [] | 130 ok_tests = [] |
131 failed_tests = [] | 131 failed_tests = [] |
132 timed_out = False | 132 timed_out = False |
133 overall_fail = False | 133 overall_fail = False |
134 re_run = re.compile('\[ RUN \] ?(.*)\r\n') | 134 re_run = re.compile('\[ RUN \] ?(.*)\r\n') |
| 135 # APK tests rely on the END tag. |
| 136 re_end = re.compile('\[ END \] ?(.*)\r\n') |
135 re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') | 137 re_fail = re.compile('\[ FAILED \] ?(.*)\r\n') |
136 re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') | 138 re_runner_fail = re.compile('\[ RUNNER_FAILED \] ?(.*)\r\n') |
137 re_ok = re.compile('\[ OK \] ?(.*)\r\n') | 139 re_ok = re.compile('\[ OK \] ?(.*)\r\n') |
138 (io_stats_before, ready_to_continue) = self._BeginGetIOStats() | 140 (io_stats_before, ready_to_continue) = self._BeginGetIOStats() |
139 while ready_to_continue: | 141 while ready_to_continue: |
140 found = p.expect([re_run, pexpect.EOF, re_runner_fail], | 142 found = p.expect([re_run, pexpect.EOF, re_end, re_runner_fail], |
141 timeout=self.timeout) | 143 timeout=self.timeout) |
142 if found == 1: # matched pexpect.EOF | 144 if found == 1: # matched pexpect.EOF |
143 break | 145 break |
144 if found == 2: # RUNNER_FAILED | 146 if found == 2: # matched END. |
| 147 break |
| 148 if found == 3: # RUNNER_FAILED |
145 logging.error('RUNNER_FAILED') | 149 logging.error('RUNNER_FAILED') |
146 overall_fail = True | 150 overall_fail = True |
147 break | 151 break |
148 if self.dump_debug_info: | 152 if self.dump_debug_info: |
149 self.dump_debug_info.TakeScreenshot('_Test_Start_Run_') | 153 self.dump_debug_info.TakeScreenshot('_Test_Start_Run_') |
150 full_test_name = p.match.group(1) | 154 full_test_name = p.match.group(1) |
151 found = p.expect([re_ok, re_fail, pexpect.EOF, pexpect.TIMEOUT], | 155 found = p.expect([re_ok, re_fail, pexpect.EOF, pexpect.TIMEOUT], |
152 timeout=self.timeout) | 156 timeout=self.timeout) |
153 if found == 0: # re_ok | 157 if found == 0: # re_ok |
154 ok_tests += [BaseTestResult(full_test_name.replace('\r', ''), | 158 ok_tests += [BaseTestResult(full_test_name.replace('\r', ''), |
(...skipping 13 matching lines...) Expand all Loading... |
168 ok_tests += self._EndGetIOStats(io_stats_before) | 172 ok_tests += self._EndGetIOStats(io_stats_before) |
169 ret_code = self._GetGTestReturnCode() | 173 ret_code = self._GetGTestReturnCode() |
170 if ret_code: | 174 if ret_code: |
171 failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, | 175 failed_tests += [BaseTestResult('gtest exit code: %d' % ret_code, |
172 'pexpect.before: %s' | 176 'pexpect.before: %s' |
173 '\npexpect.after: %s' | 177 '\npexpect.after: %s' |
174 % (p.before, | 178 % (p.before, |
175 p.after))] | 179 p.after))] |
176 return TestResults.FromOkAndFailed(ok_tests, failed_tests, | 180 return TestResults.FromOkAndFailed(ok_tests, failed_tests, |
177 timed_out, overall_fail) | 181 timed_out, overall_fail) |
OLD | NEW |