mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tests tree: build name->test map to make search for current test faster (IDEA-193091)
This commit is contained in:
+49
-27
@@ -23,9 +23,7 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
|
||||
private final Map<String, SMTestProxy> myRunningTestsFullNameToProxy = new HashMap<>();
|
||||
private final TestSuiteStack mySuitesStack;
|
||||
private final Set<SMTestProxy> myCurrentChildren = new LinkedHashSet<>();
|
||||
private boolean myGetChildren = true;
|
||||
|
||||
private final Map<String, List<SMTestProxy>> myCurrentChildren = new HashMap<>();
|
||||
|
||||
private boolean myIsTestingFinished;
|
||||
|
||||
@@ -62,6 +60,12 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
super.onSuiteTreeEnded(suiteName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBuildTreeEnded() {
|
||||
super.onBuildTreeEnded();
|
||||
initCurrentChildren(myTestsRootProxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTesting() {
|
||||
//fire
|
||||
@@ -100,6 +104,7 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
}
|
||||
mySuitesStack.clear();
|
||||
myTestsRootProxy.setFinished();
|
||||
myCurrentChildren.clear();
|
||||
|
||||
|
||||
//fire events
|
||||
@@ -146,15 +151,6 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
}
|
||||
|
||||
parentSuite.addChild(testProxy);
|
||||
|
||||
if (myTreeBuildBeforeStart && myGetChildren) {
|
||||
for (SMTestProxy proxy : parentSuite.getChildren()) {
|
||||
if (!proxy.isFinal()) {
|
||||
myCurrentChildren.add(proxy);
|
||||
}
|
||||
}
|
||||
myGetChildren = false;
|
||||
}
|
||||
}
|
||||
|
||||
// adds to running tests map
|
||||
@@ -192,7 +188,7 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
parentSuite.addChild(newSuite);
|
||||
}
|
||||
|
||||
myGetChildren = true;
|
||||
initCurrentChildren(newSuite);
|
||||
mySuitesStack.pushSuite(newSuite);
|
||||
|
||||
//Progress started
|
||||
@@ -202,6 +198,20 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
fireOnSuiteStarted(newSuite);
|
||||
}
|
||||
|
||||
private void initCurrentChildren(SMTestProxy newSuite) {
|
||||
if (myTreeBuildBeforeStart) {
|
||||
for (SMTestProxy proxy : newSuite.getChildren()) {
|
||||
if (!proxy.isFinal()) {
|
||||
String url = proxy.getLocationUrl();
|
||||
if (url != null) {
|
||||
myCurrentChildren.computeIfAbsent(url, l -> new ArrayList<>()).add(proxy);
|
||||
}
|
||||
myCurrentChildren.computeIfAbsent(proxy.getName(), l -> new ArrayList<>()).add(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SMTestProxy findChildByName(SMTestProxy parentSuite, String fullName, boolean preferSuite) {
|
||||
return findChild(parentSuite, fullName, SMTestProxy::getName, preferSuite);
|
||||
}
|
||||
@@ -216,17 +226,19 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
boolean preferSuite) {
|
||||
if (myTreeBuildBeforeStart) {
|
||||
Set<SMTestProxy> acceptedProxies = new LinkedHashSet<>();
|
||||
final Collection<? extends SMTestProxy> children = myGetChildren ? parentSuite.getChildren() : myCurrentChildren;
|
||||
for (SMTestProxy proxy : children) {
|
||||
if (fullName.equals(nameFunction.fun(proxy)) && !proxy.isFinal()) {
|
||||
acceptedProxies.add(proxy);
|
||||
Collection<? extends SMTestProxy> children = myCurrentChildren.get(fullName);
|
||||
if (children != null) { //null if child started second time
|
||||
for (SMTestProxy proxy : children) {
|
||||
if (fullName.equals(nameFunction.fun(proxy)) && !proxy.isFinal()) {
|
||||
acceptedProxies.add(proxy);
|
||||
}
|
||||
}
|
||||
if (!acceptedProxies.isEmpty()) {
|
||||
return acceptedProxies.stream()
|
||||
.filter(proxy -> proxy.isSuite() == preferSuite)
|
||||
.findFirst()
|
||||
.orElse(acceptedProxies.iterator().next());
|
||||
}
|
||||
}
|
||||
if (!acceptedProxies.isEmpty()) {
|
||||
return acceptedProxies.stream()
|
||||
.filter(proxy -> proxy.isSuite() == preferSuite)
|
||||
.findFirst()
|
||||
.orElse(acceptedProxies.iterator().next());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -249,12 +261,20 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
testProxy.setFrameworkOutputFile(testFinishedEvent.getOutputFile());
|
||||
testProxy.setFinished();
|
||||
myRunningTestsFullNameToProxy.remove(fullTestName);
|
||||
myCurrentChildren.remove(testProxy);
|
||||
clearCurrentChildren(fullTestName, testProxy);
|
||||
|
||||
//fire events
|
||||
fireOnTestFinished(testProxy);
|
||||
}
|
||||
|
||||
private void clearCurrentChildren(String fullTestName, SMTestProxy testProxy) {
|
||||
myCurrentChildren.remove(fullTestName);
|
||||
String url = testProxy.getLocationUrl();
|
||||
if (url != null) {
|
||||
myCurrentChildren.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuiteFinished(@NotNull final TestSuiteFinishedEvent suiteFinishedEvent) {
|
||||
//fire events
|
||||
@@ -262,8 +282,11 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
final SMTestProxy mySuite = mySuitesStack.popSuite(suiteName);
|
||||
if (mySuite != null) {
|
||||
mySuite.setFinished();
|
||||
myCurrentChildren.clear();
|
||||
myGetChildren = true;
|
||||
myCurrentChildren.remove(suiteName);
|
||||
String locationUrl = mySuite.getLocationUrl();
|
||||
if (locationUrl != null) {
|
||||
myCurrentChildren.remove(locationUrl);
|
||||
}
|
||||
|
||||
//fire events
|
||||
fireOnSuiteFinished(mySuite);
|
||||
@@ -420,7 +443,6 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
|
||||
// current suite shouldn't be null otherwise test runner isn't correct
|
||||
// or may be we are in debug mode
|
||||
logProblem("Current suite is undefined. Root suite will be used.");
|
||||
myGetChildren = true;
|
||||
return myTestsRootProxy;
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -264,6 +264,7 @@ public class SMTestRunnerResultsFormTest extends BaseSMTRunnerTestCase {
|
||||
myEventsProcessor.onSuiteTreeStarted("suite1", null, null, "suite1", "0");
|
||||
myEventsProcessor.onSuiteTreeNodeAdded("test1", null, null,"test1", "suite1");
|
||||
myEventsProcessor.onSuiteTreeEnded("suite1");
|
||||
myEventsProcessor.onBuildTreeEnded();
|
||||
|
||||
//start testing
|
||||
myEventsProcessor.onStartTesting();
|
||||
|
||||
Reference in New Issue
Block a user