| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 HTMLParser | 5 import HTMLParser |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import tempfile | 9 import tempfile |
| 10 import threading | 10 import threading |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 duration = 0 | 131 duration = 0 |
| 132 fallback_result_type = None | 132 fallback_result_type = None |
| 133 log = [] | 133 log = [] |
| 134 result_type = None | 134 result_type = None |
| 135 results = [] | 135 results = [] |
| 136 test_name = None | 136 test_name = None |
| 137 | 137 |
| 138 def handle_possibly_unknown_test(): | 138 def handle_possibly_unknown_test(): |
| 139 if test_name is not None: | 139 if test_name is not None: |
| 140 results.append(base_test_result.BaseTestResult( | 140 results.append(base_test_result.BaseTestResult( |
| 141 test_name, | 141 TestNameWithoutDisabledPrefix(test_name), |
| 142 fallback_result_type or base_test_result.ResultType.UNKNOWN, | 142 fallback_result_type or base_test_result.ResultType.UNKNOWN, |
| 143 duration, log=('\n'.join(log) if log else ''))) | 143 duration, log=('\n'.join(log) if log else ''))) |
| 144 | 144 |
| 145 for l in output: | 145 for l in output: |
| 146 logging.info(l) | 146 logging.info(l) |
| 147 matcher = _RE_TEST_STATUS.match(l) | 147 matcher = _RE_TEST_STATUS.match(l) |
| 148 if matcher: | 148 if matcher: |
| 149 if matcher.group(1) == 'RUN': | 149 if matcher.group(1) == 'RUN': |
| 150 handle_possibly_unknown_test() | 150 handle_possibly_unknown_test() |
| 151 duration = 0 | 151 duration = 0 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 168 if matcher: | 168 if matcher: |
| 169 test_name = matcher.group(1) | 169 test_name = matcher.group(1) |
| 170 result_type = base_test_result.ResultType.CRASH | 170 result_type = base_test_result.ResultType.CRASH |
| 171 duration = 0 # Don't know. | 171 duration = 0 # Don't know. |
| 172 | 172 |
| 173 if log is not None: | 173 if log is not None: |
| 174 log.append(l) | 174 log.append(l) |
| 175 | 175 |
| 176 if result_type and test_name: | 176 if result_type and test_name: |
| 177 results.append(base_test_result.BaseTestResult( | 177 results.append(base_test_result.BaseTestResult( |
| 178 test_name, result_type, duration, | 178 TestNameWithoutDisabledPrefix(test_name), result_type, duration, |
| 179 log=('\n'.join(log) if log else ''))) | 179 log=('\n'.join(log) if log else ''))) |
| 180 test_name = None | 180 test_name = None |
| 181 | 181 |
| 182 handle_possibly_unknown_test() | 182 handle_possibly_unknown_test() |
| 183 | 183 |
| 184 return results | 184 return results |
| 185 | 185 |
| 186 | 186 |
| 187 def ParseGTestXML(xml_content): | 187 def ParseGTestXML(xml_content): |
| 188 """Parse gtest XML result.""" | 188 """Parse gtest XML result.""" |
| 189 results = [] | 189 results = [] |
| 190 | 190 |
| 191 html = HTMLParser.HTMLParser() | 191 html = HTMLParser.HTMLParser() |
| 192 | 192 |
| 193 # TODO(jbudorick): Unclear how this handles crashes. | 193 # TODO(jbudorick): Unclear how this handles crashes. |
| 194 testsuites = xml.etree.ElementTree.fromstring(xml_content) | 194 testsuites = xml.etree.ElementTree.fromstring(xml_content) |
| 195 for testsuite in testsuites: | 195 for testsuite in testsuites: |
| 196 suite_name = testsuite.attrib['name'] | 196 suite_name = testsuite.attrib['name'] |
| 197 for testcase in testsuite: | 197 for testcase in testsuite: |
| 198 case_name = testcase.attrib['name'] | 198 case_name = testcase.attrib['name'] |
| 199 result_type = base_test_result.ResultType.PASS | 199 result_type = base_test_result.ResultType.PASS |
| 200 log = [] | 200 log = [] |
| 201 for failure in testcase: | 201 for failure in testcase: |
| 202 result_type = base_test_result.ResultType.FAIL | 202 result_type = base_test_result.ResultType.FAIL |
| 203 log.append(html.unescape(failure.attrib['message'])) | 203 log.append(html.unescape(failure.attrib['message'])) |
| 204 | 204 |
| 205 results.append(base_test_result.BaseTestResult( | 205 results.append(base_test_result.BaseTestResult( |
| 206 '%s.%s' % (suite_name, case_name), | 206 '%s.%s' % (suite_name, TestNameWithoutDisabledPrefix(case_name)), |
| 207 result_type, | 207 result_type, |
| 208 int(float(testcase.attrib['time']) * 1000), | 208 int(float(testcase.attrib['time']) * 1000), |
| 209 log=('\n'.join(log) if log else ''))) | 209 log=('\n'.join(log) if log else ''))) |
| 210 | 210 |
| 211 return results | 211 return results |
| 212 | 212 |
| 213 | 213 |
| 214 def ConvertTestFilterFileIntoGTestFilterArgument(input_lines): | 214 def ConvertTestFilterFileIntoGTestFilterArgument(input_lines): |
| 215 """Converts test filter file contents into --gtest_filter argument. | 215 """Converts test filter file contents into --gtest_filter argument. |
| 216 | 216 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 485 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
| 486 if l and not l.startswith('#')] | 486 if l and not l.startswith('#')] |
| 487 | 487 |
| 488 return '*-%s' % ':'.join(disabled_filter_items) | 488 return '*-%s' % ':'.join(disabled_filter_items) |
| 489 | 489 |
| 490 #override | 490 #override |
| 491 def TearDown(self): | 491 def TearDown(self): |
| 492 """Do nothing.""" | 492 """Do nothing.""" |
| 493 pass | 493 pass |
| 494 | 494 |
| OLD | NEW |