mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test-runner: non-null scope guarantee for AbstractTestProxy.getLocation
This commit is contained in:
+6
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 24-Dec-2008
|
||||
*/
|
||||
package com.intellij.execution.actions;
|
||||
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
@@ -29,16 +24,19 @@ import com.intellij.openapi.ui.ComponentContainer;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 24-Dec-2008
|
||||
*/
|
||||
public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
|
||||
public JavaRerunFailedTestsAction(@NotNull ComponentContainer componentContainer, @NotNull TestConsoleProperties consoleProperties) {
|
||||
super(componentContainer);
|
||||
|
||||
init(consoleProperties);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
|
||||
protected Filter getFilter(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 20-Feb-2008
|
||||
*/
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
@@ -26,18 +21,22 @@ import com.intellij.execution.junit2.info.MethodLocation;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 20-Feb-2008
|
||||
*/
|
||||
public class JavaAwareFilter {
|
||||
private JavaAwareFilter() {
|
||||
}
|
||||
private JavaAwareFilter() { }
|
||||
|
||||
public static Filter METHOD(final Project project, final GlobalSearchScope searchScope) {
|
||||
public static Filter METHOD(@NotNull final Project project, @NotNull final GlobalSearchScope searchScope) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean shouldAccept(final AbstractTestProxy test) {
|
||||
final Location location = test.getLocation(project, searchScope);
|
||||
if (location instanceof MethodLocation) return true;
|
||||
if (location instanceof PsiLocation && location.getPsiElement() instanceof PsiMethod) return true;
|
||||
return false;
|
||||
Location location = test.getLocation(project, searchScope);
|
||||
return location instanceof MethodLocation ||
|
||||
location instanceof PsiLocation && location.getPsiElement() instanceof PsiMethod;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+9
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.JavaExecutionUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
@@ -53,12 +53,15 @@ public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
return JavaExecutionUtil.findMainClass(getProject(), qualifiedName, getSearchScope());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GlobalSearchScope getSearchScope() {
|
||||
final Module module = getModule();
|
||||
Module module = getModule();
|
||||
if (module != null) {
|
||||
return myClassesInLibraries ? module.getModuleRuntimeScope(true) : GlobalSearchScope.moduleWithDependenciesScope(module);
|
||||
}
|
||||
return myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject());
|
||||
else {
|
||||
return myClassesInLibraries ? GlobalSearchScope.allScope(getProject()) : GlobalSearchScope.projectScope(getProject());
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection<Module> getModulesForClass(@NotNull final Project project, final String className) {
|
||||
@@ -68,7 +71,7 @@ public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
|
||||
final Set<Module> modules = new THashSet<Module>();
|
||||
for (PsiClass aClass : possibleClasses) {
|
||||
Module module = ModuleUtil.findModuleForPsiElement(aClass);
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(aClass);
|
||||
if (module != null) {
|
||||
modules.add(module);
|
||||
}
|
||||
@@ -79,7 +82,7 @@ public class JavaRunConfigurationModule extends RunConfigurationModule {
|
||||
else {
|
||||
final Set<Module> result = new HashSet<Module>();
|
||||
for (Module module : modules) {
|
||||
ModuleUtil.collectModulesDependsOn(module, result);
|
||||
ModuleUtilCore.collectModulesDependsOn(module, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,10 @@
|
||||
package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.MockPrinter;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.easymock.classextension.EasyMock;
|
||||
|
||||
import static com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude;
|
||||
|
||||
@@ -602,15 +604,13 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testNavigatable() {
|
||||
//noinspection NullableProblems
|
||||
assertNull(mySuite.getDescriptor(null, null));
|
||||
TestConsoleProperties properties = EasyMock.createMock(TestConsoleProperties.class);
|
||||
|
||||
assertNull(mySuite.getDescriptor(null, properties));
|
||||
|
||||
mySuite.addChild(mySimpleTest);
|
||||
|
||||
//noinspection NullableProblems
|
||||
assertNull(mySuite.getDescriptor(null, null));
|
||||
//noinspection NullableProblems
|
||||
assertNull(mySimpleTest.getDescriptor(null, null));
|
||||
assertNull(mySuite.getDescriptor(null, properties));
|
||||
assertNull(mySimpleTest.getDescriptor(null, properties));
|
||||
}
|
||||
|
||||
public void testShouldRun_Test() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 23-May-2007
|
||||
*/
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
@@ -32,15 +27,19 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 23-May-2007
|
||||
*/
|
||||
public abstract class AbstractTestProxy extends CompositePrintable {
|
||||
public static final DataKey<AbstractTestProxy> DATA_KEY = DataKey.create("testProxy");
|
||||
|
||||
protected Printer myPrinter = null;
|
||||
|
||||
public abstract boolean isInProgress();
|
||||
|
||||
public abstract boolean isDefect();
|
||||
|
||||
//todo?
|
||||
public abstract boolean shouldRun();
|
||||
|
||||
public abstract int getMagnitude();
|
||||
@@ -55,9 +54,9 @@ public abstract class AbstractTestProxy extends CompositePrintable {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract Location getLocation(final Project project, GlobalSearchScope searchScope);
|
||||
public abstract Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope);
|
||||
|
||||
public abstract Navigatable getDescriptor(final Location location, final TestConsoleProperties testConsoleProperties);
|
||||
public abstract Navigatable getDescriptor(@Nullable Location location, @NotNull TestConsoleProperties properties);
|
||||
|
||||
public abstract AbstractTestProxy getParent();
|
||||
|
||||
|
||||
+2
@@ -80,6 +80,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GlobalSearchScope getScope() {
|
||||
if (myScope == null) {
|
||||
myScope = initScope();
|
||||
@@ -87,6 +88,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
return myScope;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected GlobalSearchScope initScope() {
|
||||
RunConfiguration configuration = getConfiguration();
|
||||
if (!(configuration instanceof ModuleRunProfile)) {
|
||||
|
||||
+9
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 24-Dec-2008
|
||||
*/
|
||||
package com.intellij.execution.testframework.actions;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
@@ -62,6 +57,10 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 24-Dec-2008
|
||||
*/
|
||||
public class AbstractRerunFailedTestsAction extends AnAction implements AnAction.TransparentUpdate {
|
||||
private static final Logger LOG = Logger.getInstance(AbstractRerunFailedTestsAction.class);
|
||||
|
||||
@@ -112,16 +111,15 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected List<AbstractTestProxy> getFailedTests(Project project) {
|
||||
protected List<AbstractTestProxy> getFailedTests(@NotNull Project project) {
|
||||
TestFrameworkRunningModel model = getModel();
|
||||
if (model == null) return Collections.emptyList();
|
||||
//noinspection unchecked
|
||||
return getFilter(project, model != null ? model.getProperties().getScope() : GlobalSearchScope.allScope(project)).select(model != null
|
||||
? model.getRoot().getAllTests()
|
||||
: Collections.<AbstractTestProxy>emptyList());
|
||||
return getFilter(project, model.getProperties().getScope()).select(model.getRoot().getAllTests());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
|
||||
protected Filter getFilter(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
return getFailuresFilter();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ public class GradleSMTestProxy extends SMTestProxy {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Location getLocation(Project project, GlobalSearchScope searchScope) {
|
||||
public Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
if (getLocationUrl() != null) {
|
||||
if (isDefect() && myStacktrace != null) {
|
||||
final String[] stackTrace = new LineTokenizer(myStacktrace).execute();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.execution.junit2;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
@@ -110,7 +109,7 @@ public class TestProxy extends AbstractTestProxy {
|
||||
return myParent;
|
||||
}
|
||||
|
||||
public Navigatable getDescriptor(final Location location, final TestConsoleProperties testConsoleProperties) {
|
||||
public Navigatable getDescriptor(@Nullable Location location, @NotNull TestConsoleProperties properties) {
|
||||
return getState().getDescriptor(location);
|
||||
}
|
||||
|
||||
@@ -134,7 +133,7 @@ public class TestProxy extends AbstractTestProxy {
|
||||
return getState().getMagnitude();
|
||||
}
|
||||
|
||||
public Location getLocation(final Project project, GlobalSearchScope searchScope) {
|
||||
public Location getLocation(@NotNull final Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
final Location location = getInfo().getLocation(project, searchScope);
|
||||
if (location == null) {
|
||||
return checkParentParameterized(project, searchScope);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.execution.junit2.ui.properties;
|
||||
|
||||
import com.intellij.execution.Executor;
|
||||
@@ -36,6 +35,7 @@ public class JUnitConsoleProperties extends JavaAwareTestConsoleProperties<JUnit
|
||||
myConfiguration = configuration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected GlobalSearchScope initScope() {
|
||||
final SourceScope sourceScope = myConfiguration.getPersistentData().getScope().getSourceScope(myConfiguration);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.execution.testframework.JavaAwareTestConsoleProperties;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.theoryinpractice.testng.configuration.TestNGConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -34,6 +35,7 @@ public class TestNGConsoleProperties extends JavaAwareTestConsoleProperties<Test
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected GlobalSearchScope initScope() {
|
||||
return myConfiguration.getPersistantData().getScope().getSourceScope(myConfiguration).getGlobalSearchScope();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,9 +28,8 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.testng.remote.strprotocol.MessageHelper;
|
||||
import org.testng.remote.strprotocol.TestResultMessage;
|
||||
@@ -161,7 +160,7 @@ public class TestProxy extends AbstractTestProxy {
|
||||
return !isNotPassed();
|
||||
}
|
||||
|
||||
public Location getLocation(final Project project, GlobalSearchScope searchScope) {
|
||||
public Location getLocation(@NotNull final Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
if (psiElement == null) return null;
|
||||
final PsiElement element = psiElement.getElement();
|
||||
if (element == null) return null;
|
||||
@@ -169,7 +168,7 @@ public class TestProxy extends AbstractTestProxy {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Navigatable getDescriptor(final Location location, final TestConsoleProperties testConsoleProperties) {
|
||||
public Navigatable getDescriptor(@Nullable Location location, @NotNull TestConsoleProperties properties) {
|
||||
if (location == null) return null;
|
||||
return EditSourceUtil.getDescriptor(location.getPsiElement());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user