use of com.facebook.buck.test.TestResultSummary in project buck by facebook.
the class TestCaseSummariesBuildingXctoolEventHandler method handleEndTestEvent.
@Override
public void handleEndTestEvent(XctoolOutputParsing.EndTestEvent event) {
TestResultSummary testResultSummary = XctoolOutputParsing.testResultSummaryForEndTestEvent(event);
testResultSummariesBuilder.put(Preconditions.checkNotNull(event.className), testResultSummary);
testReportingCallback.testDidEnd(testResultSummary);
}
use of com.facebook.buck.test.TestResultSummary in project buck by facebook.
the class XctestOutputParsing method testResultSummaryForEndTestCaseEvent.
public static TestResultSummary testResultSummaryForEndTestCaseEvent(EndTestCaseEvent event) {
long timeMillis = (long) (event.totalDuration * TimeUnit.SECONDS.toMillis(1));
TestResultSummary testResultSummary = new TestResultSummary(Optional.ofNullable(event.className).orElse(Preconditions.checkNotNull(event.test)), Optional.ofNullable(event.methodName).orElse(Preconditions.checkNotNull(event.test)), event.succeeded ? ResultType.SUCCESS : ResultType.FAILURE, timeMillis, formatTestMessage(event), // stackTrace,
null, formatTestOutput(event), // stderr
null);
LOG.debug("Test result summary: %s", testResultSummary);
return testResultSummary;
}
use of com.facebook.buck.test.TestResultSummary in project buck by facebook.
the class XctoolOutputParsing method internalErrorForEndOcunitEvent.
public static Optional<TestResultSummary> internalErrorForEndOcunitEvent(EndOcunitEvent endOcunitEvent) {
if (endOcunitEvent.succeeded || endOcunitEvent.message == null) {
// happen with any random test failure.)
return Optional.empty();
}
TestResultSummary testResultSummary = new TestResultSummary("Internal error from test runner", "main", ResultType.FAILURE, 0L, endOcunitEvent.message, // stackTrace,
null, // stdOut
null, // stdErr
null);
LOG.debug("OCUnit/XCTest internal failure: %s", testResultSummary);
return Optional.of(testResultSummary);
}
use of com.facebook.buck.test.TestResultSummary in project buck by facebook.
the class XctoolOutputParsing method testResultSummaryForEndTestEvent.
public static TestResultSummary testResultSummaryForEndTestEvent(EndTestEvent endTestEvent) {
long timeMillis = (long) (endTestEvent.totalDuration * TimeUnit.SECONDS.toMillis(1));
TestResultSummary testResultSummary = new TestResultSummary(Preconditions.checkNotNull(endTestEvent.className), Preconditions.checkNotNull(endTestEvent.test), endTestEvent.succeeded ? ResultType.SUCCESS : ResultType.FAILURE, timeMillis, formatTestMessage(endTestEvent), // stackTrace,
null, formatTestStdout(endTestEvent), // stdErr
null);
LOG.debug("Test result summary: %s", testResultSummary);
return testResultSummary;
}
use of com.facebook.buck.test.TestResultSummary in project buck by facebook.
the class CxxBoostTest method parseResults.
@Override
protected ImmutableList<TestResultSummary> parseResults(Path exitCode, Path output, Path results) throws Exception {
ImmutableList.Builder<TestResultSummary> summariesBuilder = ImmutableList.builder();
// Process the test run output to grab the individual test stdout/stderr and
// test run times.
Map<String, String> messages = Maps.newHashMap();
Map<String, List<String>> stdout = Maps.newHashMap();
Map<String, Long> times = Maps.newHashMap();
try (BufferedReader reader = Files.newBufferedReader(output, Charsets.US_ASCII)) {
Stack<String> testSuite = new Stack<>();
Optional<String> currentTest = Optional.empty();
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher;
if ((matcher = SUITE_START.matcher(line)).matches()) {
String suite = matcher.group(1);
testSuite.push(suite);
} else if ((matcher = SUITE_END.matcher(line)).matches()) {
String suite = matcher.group(1);
Preconditions.checkState(testSuite.peek().equals(suite));
testSuite.pop();
} else if ((matcher = CASE_START.matcher(line)).matches()) {
String test = Joiner.on(".").join(testSuite) + "." + matcher.group(1);
currentTest = Optional.of(test);
stdout.put(test, Lists.newArrayList());
} else if ((matcher = CASE_END.matcher(line)).matches()) {
String test = Joiner.on(".").join(testSuite) + "." + matcher.group(1);
Preconditions.checkState(currentTest.isPresent() && currentTest.get().equals(test));
String time = matcher.group(2);
times.put(test, time == null ? 0 : Long.valueOf(time));
currentTest = Optional.empty();
} else if (currentTest.isPresent()) {
if (ERROR.matcher(line).matches()) {
messages.put(currentTest.get(), line);
} else {
Preconditions.checkNotNull(stdout.get(currentTest.get())).add(line);
}
}
}
}
// Parse the XML result file for the actual test result summaries.
Document doc = XmlDomParser.parse(results);
Node testResult = doc.getElementsByTagName("TestResult").item(0);
Node testSuite = testResult.getFirstChild();
visitTestSuite(summariesBuilder, messages, stdout, times, "", testSuite);
return summariesBuilder.build();
}
Aggregations