mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-138301 added rejecting of pattern test configuration for empty test set
This commit is contained in:
committed by
Sergei Vorobyov
parent
b4bc0b541b
commit
dfca52f936
+16
-2
@@ -24,6 +24,7 @@ import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleExternalTaskConfigurationType;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
import java.util.*;
|
||||
@@ -55,6 +56,7 @@ public final class PatternGradleConfigurationProducer extends GradleTestRunConfi
|
||||
assert contextLocation != null;
|
||||
Project project = context.getProject();
|
||||
List<String> tests = getTestPatterns(context);
|
||||
if (tests.isEmpty()) return false;
|
||||
TestMappings testMappings = getTestMappings(project, tests);
|
||||
Function1<String, VirtualFile> findTestSource = test -> getSourceFile(testMappings.getClasses().get(test));
|
||||
Function1<String, String> createFilter = (test) ->
|
||||
@@ -62,7 +64,7 @@ public final class PatternGradleConfigurationProducer extends GradleTestRunConfi
|
||||
Module module = getModuleFromContext(context);
|
||||
if (module == null) return false;
|
||||
if (!applyTestConfiguration(settings, module, tests, findTestSource, createFilter)) return false;
|
||||
configuration.setName(tests.size() > 1 ? String.format("%s and %d more", tests.get(0), tests.size() - 1) : tests.get(0));
|
||||
configuration.setName(suggestConfigurationName(tests));
|
||||
JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, contextLocation);
|
||||
return true;
|
||||
}
|
||||
@@ -89,6 +91,11 @@ public final class PatternGradleConfigurationProducer extends GradleTestRunConfi
|
||||
ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration)fromContext.getConfiguration();
|
||||
Project project = context.getProject();
|
||||
List<String> tests = getTestPatterns(context);
|
||||
if (tests.isEmpty()) {
|
||||
LOG.warn("Cannot find runnable tests from context, uses raw run configuration");
|
||||
performRunnable.run();
|
||||
return;
|
||||
}
|
||||
TestMappings testMappings = getTestMappings(project, tests);
|
||||
getTestTasksChooser().chooseTestTasks(project, context.getDataContext(), testMappings.getClasses().values(), tasks -> {
|
||||
ExternalSystemTaskExecutionSettings settings = configuration.getSettings();
|
||||
@@ -100,11 +107,18 @@ public final class PatternGradleConfigurationProducer extends GradleTestRunConfi
|
||||
performRunnable.run();
|
||||
return;
|
||||
}
|
||||
configuration.setName(tests.size() > 1 ? String.format("%s and %d more", tests.get(0), tests.size() - 1) : tests.get(0));
|
||||
configuration.setName(suggestConfigurationName(tests));
|
||||
performRunnable.run();
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String suggestConfigurationName(List<String> tests) {
|
||||
if (tests.isEmpty()) return "";
|
||||
if (tests.size() == 1) return tests.get(0);
|
||||
return GradleBundle.message("gradle.tests.pattern.producer.configuration.name", tests.get(0), tests.size() - 1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Module getModuleFromContext(ConfigurationContext context) {
|
||||
Module module = context.getModule();
|
||||
|
||||
@@ -70,4 +70,5 @@ gradle.settings.title.debug=Gradle Debug
|
||||
gradle.tests.tasks.choosing.popup.title.common=Run Tasks
|
||||
gradle.tests.tasks.choosing.popup.title=Run Tasks for {0}
|
||||
gradle.tests.tasks.choosing.popup.hint=Select several tasks to run them at once
|
||||
gradle.tests.tasks.choosing.warning.text=No tasks available
|
||||
gradle.tests.tasks.choosing.warning.text=No tasks available
|
||||
gradle.tests.pattern.producer.configuration.name={0} and {1} more
|
||||
Reference in New Issue
Block a user