Add support for testing of xml and json output of source file and line location

This commit is contained in:
Szymon Sobik 2022-03-08 01:14:21 +01:00
parent f7621f0191
commit ee5e3043ce
2 changed files with 6 additions and 0 deletions

View File

@ -50,6 +50,8 @@ def normalize(obj):
elif key == 'failure':
value = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', value)
return re.sub(r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', value)
elif key == 'file':
return re.sub(r'^.*[/\\](.*)', '\\1', value)
else:
return normalize(value)
if isinstance(obj, dict):

View File

@ -170,6 +170,10 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
* The stack traces are removed.
"""
if element.tagName == 'testcase':
source_file = element.getAttributeNode('file')
if source_file:
source_file.value = re.sub(r'^.*[/\\](.*)', '\\1', source_file.value)
if element.tagName in ('testsuites', 'testsuite', 'testcase'):
timestamp = element.getAttributeNode('timestamp')
timestamp.value = re.sub(r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\d$',