@Override
public boolean isConfigurationFromContext(RunConfiguration configuration, ConfigurationContext context) {
if (configuration.getType() != getConfigurationType())
return false;
GoFile file = locationToFile(context.getLocation());
if (file == null || !file.getName().endsWith("_test.go")) {
return false;
}
PsiElement target = locationToTestFunction(context.getPsiLocation());
GoTestConfiguration testConfig = (GoTestConfiguration) configuration;
try {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
return false;
Project project = file.getProject();
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
GoApplicationModuleBasedConfiguration configurationModule = testConfig.getConfigurationModule();
String packageName = file.getPackageName();
if (!StringUtil.equals(testConfig.packageDir, file.getContainingDirectory().getVirtualFile().getCanonicalPath()) ||
!StringUtil.equals(testConfig.workingDir, project.getBasePath()) ||
!(testConfig.testTargetType == GoTestConfiguration.TestTargetType.Package) ||
!(StringUtil.equals(packageName, file.getPackageName())) ||
!(configurationModule != null && module != null && module.equals(configurationModule.getModule())))
return false;
if (target instanceof GoFile) {
GoTestConfiguration.Type executionMode =