diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-22 01:38:42 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-24 00:51:54 +0200 |
commit | 67c877562b18ea5c591d2884d2b14f7bf3a39149 (patch) | |
tree | efac919ee2f72dacb1df53896754d501640890a2 /src/testlib | |
parent | c70d693378b8110c09fdd18d7a4a22e8bd1b98d9 (diff) |
testlib: Output JUnitXML attributes in right order
The attributes are, like the elements, maintained in reverse
order in the underlying QTestCoreList, so we need to iterate
them backwards when printing out the resulting XML to reflect
the order they were added.
This results in e.g.:
<testcase name="passingBenchmark" result="pass">
Instead of:
<testcase result="pass" name="passingBenchmark">
Change-Id: Ic2eeab8de05ffedd0c41977358d5b40ff77878b1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qtestjunitstreamer.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/testlib/qtestjunitstreamer.cpp b/src/testlib/qtestjunitstreamer.cpp index 9c3a9c9ca5..844f80f90c 100644 --- a/src/testlib/qtestjunitstreamer.cpp +++ b/src/testlib/qtestjunitstreamer.cpp @@ -176,13 +176,12 @@ void QTestJUnitStreamer::outputElements(QTestElement *element, bool) const { QTestCharBuffer buf; bool hasChildren; - /* - Elements are in reverse order of occurrence, so start from the end and work - our way backwards. - */ - while (element && element->nextElement()) { + + // Elements are in reverse order of occurrence, so + // start from the end and work our way backwards. + while (element && element->nextElement()) element = element->nextElement(); - } + while (element) { hasChildren = element->childElements(); @@ -208,10 +207,16 @@ void QTestJUnitStreamer::outputElements(QTestElement *element, bool) const void QTestJUnitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const { QTestCharBuffer buf; + + // Attributes are in reverse order of occurrence, so + // start from the end and work our way backwards. + while (attribute && attribute->nextElement()) + attribute = attribute->nextElement(); + while (attribute) { formatAttributes(element, attribute, &buf); outputString(buf.data()); - attribute = attribute->nextElement(); + attribute = attribute->previousElement(); } } |