Gabriel B. has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/66892?usp=email )
Change subject: ext-testlib: Improve error reporting when test definition
fails
......................................................................
ext-testlib: Improve error reporting when test definition fails
The error reason is now reported as an element in the XML testing result
summary.
Change-Id: I18b84422bb9580709cf1c5f2a14a5cbb0caf1876
---
M ext/testlib/result.py
1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/ext/testlib/result.py b/ext/testlib/result.py
index 5c60342..786febd 100644
--- a/ext/testlib/result.py
+++ b/ext/testlib/result.py
@@ -191,17 +191,23 @@
def begin(self, file_):
file_.write('<')
file_.write(self.name)
- for attr in self.attributes:
- file_.write(' ')
- attr.write(file_)
+ if hasattr(self, 'attributes'):
+ for attr in self.attributes:
+ file_.write(' ')
+ attr.write(file_)
file_.write('>')
self.body(file_)
def body(self, file_):
- for elem in self.elements:
- file_.write('\n')
- elem.write(file_)
+ if hasattr(self, 'elements'):
+ for elem in self.elements:
+ file_.write('\n')
+ elem.write(file_)
+ if hasattr(self, 'content'):
+ file_.write('\n')
+ file_.write(
+ xml.sax.saxutils.escape(self.content))
file_.write('\n')
def end(self, file_):
@@ -286,17 +292,22 @@
]
if str(test_result.result) == 'Failed':
- self.elements.append(JUnitFailure('Test failed', 'ERROR'))
+ self.elements.append(JUnitFailure(
+ 'Test failed',
+ str(test_result.result.reason))
+ )
class JUnitFailure(XMLElement):
name = 'failure'
- def __init__(self, message, fail_type):
+ def __init__(self, message, cause):
self.attributes = [
XMLAttribute('message', message),
- XMLAttribute('type', fail_type),
]
- self.elements = []
+ cause_element = XMLElement()
+ cause_element.name = 'cause'
+ cause_element.content = cause
+ self.elements = [cause_element]
class LargeFileElement(XMLElement):
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/66892?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I18b84422bb9580709cf1c5f2a14a5cbb0caf1876
Gerrit-Change-Number: 66892
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. <gabriel.bus...@arteris.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org