use of com.google.idea.blaze.base.run.testlogs.BlazeTestResult.TestStatus in project intellij by bazelbuild.
the class BlazeXmlToTestEventsConverter method processTestSuites.
/**
* Process all test XML files from a single test target.
*/
private void processTestSuites(Label label, Collection<BlazeTestResult> results) {
List<File> outputFiles = new ArrayList<>();
results.forEach(result -> outputFiles.addAll(result.getOutputXmlFiles()));
if (noUsefulOutput(results, outputFiles)) {
Optional<TestStatus> status = results.stream().map(BlazeTestResult::getTestStatus).findFirst();
status.ifPresent(testStatus -> reportTargetWithoutOutputFiles(label, testStatus));
return;
}
List<TestSuite> targetSuites = new ArrayList<>();
for (File file : outputFiles) {
try (InputStream input = new FileInputStream(file)) {
targetSuites.add(BlazeXmlSchema.parse(input));
} catch (Exception e) {
// ignore parsing errors -- most common cause is user cancellation, which we can't easily
// recognize.
}
}
if (targetSuites.isEmpty()) {
return;
}
Kind kind = results.stream().map(BlazeTestResult::getTargetKind).filter(Objects::nonNull).findFirst().orElse(null);
BlazeTestEventsHandler eventsHandler = BlazeTestEventsHandler.getHandlerForTargetKindOrFallback(kind);
TestSuite suite = targetSuites.size() == 1 ? targetSuites.get(0) : BlazeXmlSchema.mergeSuites(targetSuites);
processTestSuite(getProcessor(), eventsHandler, kind, suite);
}
Aggregations