IDEA-139154 Gradle Single Test Prints "Empty test suite."; IDEA-146601 Gradle: blinking non-relevant tests

This commit is contained in:
Vladislav.Soroka
2015-10-22 15:25:21 +03:00
parent c49ff1a05f
commit b5ff2a9846
7 changed files with 51 additions and 23 deletions
@@ -33,6 +33,7 @@ public class GradleSMTestProxy extends SMTestProxy {
@Nullable private final String myClassName;
@Nullable private String myStacktrace;
@Nullable private String myParentId;
public GradleSMTestProxy(String testName, boolean isSuite, @Nullable String locationUrl, @Nullable String className) {
super(testName, isSuite, locationUrl);
@@ -78,6 +79,15 @@ public class GradleSMTestProxy extends SMTestProxy {
return super.getLocation(project, searchScope);
}
@Nullable
public String getParentId() {
return myParentId;
}
public void setParentId(@Nullable String parentId) {
myParentId = parentId;
}
private void setStacktraceIfNotSet(@Nullable String stacktrace) {
if (myStacktrace == null) myStacktrace = stacktrace;
}
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.gradle.execution.test.runner.events;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.execution.testframework.sm.runner.ui.SMTestRunnerResultsForm;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.project.Project;
@@ -79,4 +80,13 @@ public abstract class AbstractTestEvent implements TestEvent {
protected void addToInvokeLater(final Runnable runnable) {
ExternalSystemApiUtil.addToInvokeLater(runnable);
}
@Nullable
protected SMTestProxy findTestProxy(final String proxyId) {
return getConsoleManager().getTestsMap().get(proxyId);
}
protected void registerTestProxy(final String proxyId, SMTestProxy testProxy) {
getConsoleManager().getTestsMap().put(proxyId, testProxy);
}
}
@@ -36,7 +36,7 @@ public class AfterSuiteEvent extends AbstractTestEvent {
addToInvokeLater(new Runnable() {
@Override
public void run() {
final SMTestProxy testProxy = getConsoleManager().getTestsMap().get(testId);
final SMTestProxy testProxy = findTestProxy(testId);
if (testProxy == null) return;
switch (result) {
@@ -53,9 +53,6 @@ public class AfterSuiteEvent extends AbstractTestEvent {
break;
}
if (testProxy.isEmptySuite() && !(testProxy instanceof SMTestProxy.SMRootTestProxy)) {
testProxy.getParent().getChildren().remove(testProxy);
}
getResultsViewer().onSuiteFinished(testProxy);
}
});
@@ -45,7 +45,7 @@ public class AfterTestEvent extends AbstractTestEvent {
final String exceptionMsg = eventXml.queryXml("/ijLog/event/test/result/errorMsg");
final String stackTrace = eventXml.queryXml("/ijLog/event/test/result/stackTrace");
final SMTestProxy testProxy = getConsoleManager().getTestsMap().get(testId);
final SMTestProxy testProxy = findTestProxy(testId);
if (testProxy == null) return;
try {
@@ -15,8 +15,8 @@
*/
package org.jetbrains.plugins.gradle.execution.test.runner.events;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.plugins.gradle.execution.test.runner.GradleSMTestProxy;
import org.jetbrains.plugins.gradle.util.XmlXpathHelper;
import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestsExecutionConsoleManager;
@@ -37,24 +37,15 @@ public class BeforeSuiteEvent extends AbstractTestEvent {
final String fqClassName = getTestClassName(eventXml);
if (StringUtil.isEmpty(parentTestId)) {
getConsoleManager().getTestsMap().put(testId, getResultsViewer().getTestsRootNode());
registerTestProxy(testId, getResultsViewer().getTestsRootNode());
}
else {
String locationUrl = findLocationUrl(null, fqClassName);
final SMTestProxy testProxy = new SMTestProxy(name, true, locationUrl);
final GradleSMTestProxy testProxy = new GradleSMTestProxy(name, true, locationUrl, null);
testProxy.setLocator(getConsoleManager().getUrlProvider());
testProxy.setParentId(parentTestId);
testProxy.setStarted();
getConsoleManager().getTestsMap().put(testId, testProxy);
final SMTestProxy parentTestProxy = getConsoleManager().getTestsMap().get(parentTestId);
if (parentTestProxy != null) {
addToInvokeLater(new Runnable() {
@Override
public void run() {
parentTestProxy.addChild(testProxy);
getResultsViewer().onSuiteStarted(testProxy);
}
});
}
registerTestProxy(testId, testProxy);
}
}
}
@@ -17,9 +17,12 @@ package org.jetbrains.plugins.gradle.execution.test.runner.events;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.plugins.gradle.util.XmlXpathHelper;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.plugins.gradle.execution.test.runner.GradleSMTestProxy;
import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestsExecutionConsoleManager;
import org.jetbrains.plugins.gradle.util.XmlXpathHelper;
import java.util.List;
/**
* @author Vladislav.Soroka
@@ -43,7 +46,7 @@ public class BeforeTestEvent extends AbstractTestEvent {
testProxy.setStarted();
testProxy.setLocator(getConsoleManager().getUrlProvider());
getConsoleManager().getTestsMap().put(testId, testProxy);
registerTestProxy(testId, testProxy);
if (StringUtil.isEmpty(parentTestId)) {
addToInvokeLater(new Runnable() {
@@ -54,11 +57,28 @@ public class BeforeTestEvent extends AbstractTestEvent {
});
}
else {
final SMTestProxy parentTestProxy = getConsoleManager().getTestsMap().get(parentTestId);
final SMTestProxy parentTestProxy = findTestProxy(parentTestId);
if (parentTestProxy != null) {
addToInvokeLater(new Runnable() {
@Override
public void run() {
final List<GradleSMTestProxy> notYetAddedParents = ContainerUtil.newSmartList();
SMTestProxy currentParentTestProxy = parentTestProxy;
while (currentParentTestProxy != null && currentParentTestProxy instanceof GradleSMTestProxy) {
final String parentId = ((GradleSMTestProxy)currentParentTestProxy).getParentId();
if (currentParentTestProxy.getParent() == null && parentId != null) {
notYetAddedParents.add((GradleSMTestProxy)currentParentTestProxy);
}
currentParentTestProxy = findTestProxy(parentId);
}
for (GradleSMTestProxy gradleSMTestProxy : ContainerUtil.reverse(notYetAddedParents)) {
final SMTestProxy parentTestProxy = findTestProxy(gradleSMTestProxy.getParentId());
if (parentTestProxy != null) {
parentTestProxy.addChild(gradleSMTestProxy);
getResultsViewer().onSuiteStarted(gradleSMTestProxy);
}
}
parentTestProxy.addChild(testProxy);
}
});
@@ -36,7 +36,7 @@ public class OnOutputEvent extends AbstractTestEvent {
final String destination = eventXml.queryXml("/ijLog/event/test/event/@destination");
final String output = eventXml.queryXml("/ijLog/event/test/event");
SMTestProxy testProxy = getConsoleManager().getTestsMap().get(testId);
SMTestProxy testProxy = findTestProxy(testId);
if (testProxy == null) return;
testProxy.addStdOutput(output, "StdOut".equals(destination) ? ProcessOutputTypes.STDOUT : ProcessOutputTypes.STDERR);