8263659: Reflow GTestResultParser for better readability
Reviewed-by: shade, iignatyev
This commit is contained in:
parent
e333b6e153
commit
21db0f6768
@ -21,6 +21,7 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import javax.xml.XMLConstants;
|
||||||
import javax.xml.stream.XMLInputFactory;
|
import javax.xml.stream.XMLInputFactory;
|
||||||
import javax.xml.stream.XMLStreamConstants;
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
@ -39,34 +40,32 @@ public class GTestResultParser {
|
|||||||
public GTestResultParser(Path file) {
|
public GTestResultParser(Path file) {
|
||||||
List<String> failedTests = new ArrayList<>();
|
List<String> failedTests = new ArrayList<>();
|
||||||
try (Reader r = Files.newBufferedReader(file)) {
|
try (Reader r = Files.newBufferedReader(file)) {
|
||||||
try {
|
XMLInputFactory factory = XMLInputFactory.newInstance();
|
||||||
XMLStreamReader xmlReader = XMLInputFactory.newInstance()
|
factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
||||||
.createXMLStreamReader(r);
|
factory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
|
||||||
String testSuite = null;
|
XMLStreamReader xmlReader = factory.createXMLStreamReader(r);
|
||||||
String testCase = null;
|
String testSuite = null;
|
||||||
while (xmlReader.hasNext()) {
|
String testCase = null;
|
||||||
switch (xmlReader.next()) {
|
while (xmlReader.hasNext()) {
|
||||||
case XMLStreamConstants.START_ELEMENT:
|
int code = xmlReader.next();
|
||||||
switch (xmlReader.getLocalName()) {
|
if (code == XMLStreamConstants.START_ELEMENT) {
|
||||||
case "testsuite":
|
switch (xmlReader.getLocalName()) {
|
||||||
testSuite = xmlReader.getAttributeValue("", "name");
|
case "testsuite":
|
||||||
break;
|
testSuite = xmlReader.getAttributeValue("", "name");
|
||||||
case "testcase":
|
break;
|
||||||
testCase = xmlReader.getAttributeValue("", "name");
|
case "testcase":
|
||||||
break;
|
testCase = xmlReader.getAttributeValue("", "name");
|
||||||
case "failure":
|
break;
|
||||||
failedTests.add(testSuite + "::" + testCase);
|
case "failure":
|
||||||
default:
|
failedTests.add(testSuite + "::" + testCase);
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (XMLStreamException e) {
|
|
||||||
throw new IllegalArgumentException("can't open parse xml " + file, e);
|
|
||||||
}
|
}
|
||||||
|
} catch (XMLStreamException e) {
|
||||||
|
throw new IllegalArgumentException("can't open parse xml " + file, e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalArgumentException("can't open result file " + file, e);
|
throw new IllegalArgumentException("can't open result file " + file, e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user