use of com.google.idea.blaze.base.run.testlogs.BlazeTestResults in project intellij by bazelbuild.
the class BlazeXmlToTestEventsConverter method processTestSuites.
@Override
public void processTestSuites() {
onStartTesting();
getProcessor().onTestsReporterAttached();
BlazeTestResults testResults = testResultFinderStrategy.findTestResults();
if (testResults == null) {
return;
}
try {
for (Label label : testResults.perTargetResults.keySet()) {
processTestSuites(label, testResults.perTargetResults.get(label));
}
} finally {
testResultFinderStrategy.deleteTemporaryOutputXmlFiles();
}
}
use of com.google.idea.blaze.base.run.testlogs.BlazeTestResults in project intellij by bazelbuild.
the class BuildEventProtocolOutputReaderTest method parseTestResults_singleEvent_returnsTestResults.
@Test
public void parseTestResults_singleEvent_returnsTestResults() throws IOException {
Label label = Label.create("//java/com/google:unit_tests");
BuildEventStreamProtos.TestStatus status = BuildEventStreamProtos.TestStatus.FAILED;
ImmutableList<String> filePaths = ImmutableList.of("/usr/local/tmp/_cache/test_result.xml");
BuildEvent.Builder event = testResultEvent(label.toString(), status, filePaths);
BlazeTestResults results = BuildEventProtocolOutputReader.parseTestResults(asInputStream(event));
assertThat(results.perTargetResults.keySet()).containsExactly(label);
assertThat(results.perTargetResults.get(label)).hasSize(1);
BlazeTestResult result = results.perTargetResults.get(label).iterator().next();
assertThat(result.getTestStatus()).isEqualTo(TestStatus.FAILED);
assertThat(result.getOutputXmlFiles()).containsExactly(new File("/usr/local/tmp/_cache/test_result.xml"));
}
use of com.google.idea.blaze.base.run.testlogs.BlazeTestResults in project intellij by bazelbuild.
the class BuildEventProtocolOutputReaderTest method parseTestResults_multipleEvents_returnsAllResults.
@Test
public void parseTestResults_multipleEvents_returnsAllResults() throws IOException {
BuildEvent.Builder test1 = testResultEvent("//java/com/google:Test1", BuildEventStreamProtos.TestStatus.PASSED, ImmutableList.of("/usr/local/tmp/_cache/test_result.xml"));
BuildEvent.Builder test2 = testResultEvent("//java/com/google:Test2", BuildEventStreamProtos.TestStatus.INCOMPLETE, ImmutableList.of("/usr/local/tmp/_cache/second_result.xml"));
BlazeTestResults results = BuildEventProtocolOutputReader.parseTestResults(asInputStream(test1, test2));
assertThat(results.perTargetResults).hasSize(2);
assertThat(results.perTargetResults.get(Label.create("//java/com/google:Test1"))).hasSize(1);
assertThat(results.perTargetResults.get(Label.create("//java/com/google:Test2"))).hasSize(1);
BlazeTestResult result1 = results.perTargetResults.get(Label.create("//java/com/google:Test1")).iterator().next();
assertThat(result1.getTestStatus()).isEqualTo(TestStatus.PASSED);
assertThat(result1.getOutputXmlFiles()).containsExactly(new File("/usr/local/tmp/_cache/test_result.xml"));
BlazeTestResult result2 = results.perTargetResults.get(Label.create("//java/com/google:Test2")).iterator().next();
assertThat(result2.getTestStatus()).isEqualTo(TestStatus.INCOMPLETE);
assertThat(result2.getOutputXmlFiles()).containsExactly(new File("/usr/local/tmp/_cache/second_result.xml"));
}
use of com.google.idea.blaze.base.run.testlogs.BlazeTestResults in project intellij by bazelbuild.
the class BuildEventProtocolOutputReaderTest method parseTestResults_singleEvent_ignoresNonXmlOutputFiles.
@Test
public void parseTestResults_singleEvent_ignoresNonXmlOutputFiles() throws IOException {
Label label = Label.create("//java/com/google:unit_tests");
BuildEventStreamProtos.TestStatus status = BuildEventStreamProtos.TestStatus.FAILED;
ImmutableList<String> filePaths = ImmutableList.of("/usr/local/tmp/_cache/test_result.xml", "/usr/local/tmp/_cache/test_result.log", "/usr/local/tmp/other_output_file");
BuildEvent.Builder event = testResultEvent(label.toString(), status, filePaths);
BlazeTestResults results = BuildEventProtocolOutputReader.parseTestResults(asInputStream(event));
BlazeTestResult result = results.perTargetResults.get(label).iterator().next();
assertThat(result.getOutputXmlFiles()).containsExactly(new File("/usr/local/tmp/_cache/test_result.xml"));
}
use of com.google.idea.blaze.base.run.testlogs.BlazeTestResults in project intellij by bazelbuild.
the class BuildEventProtocolOutputReaderTest method parseTestResults_singleTargetWithMultipleEvents_returnsTestResults.
@Test
public void parseTestResults_singleTargetWithMultipleEvents_returnsTestResults() throws IOException {
Label label = Label.create("//java/com/google:unit_tests");
BuildEventStreamProtos.TestStatus status = BuildEventStreamProtos.TestStatus.PASSED;
BuildEvent.Builder shard1 = testResultEvent(label.toString(), status, ImmutableList.of("/usr/local/tmp/_cache/shard1_of_2.xml"));
BuildEvent.Builder shard2 = testResultEvent(label.toString(), status, ImmutableList.of("/usr/local/tmp/_cache/shard2_of_2.xml"));
BlazeTestResults results = BuildEventProtocolOutputReader.parseTestResults(asInputStream(shard1, shard2));
assertThat(results.perTargetResults).hasSize(2);
Collection<BlazeTestResult> targetResults = results.perTargetResults.get(label);
assertThat(targetResults).containsExactly(BlazeTestResult.create(label, null, TestStatus.PASSED, ImmutableSet.of(new File("/usr/local/tmp/_cache/shard1_of_2.xml"))), BlazeTestResult.create(label, null, TestStatus.PASSED, ImmutableSet.of(new File("/usr/local/tmp/_cache/shard2_of_2.xml"))));
}
Aggregations