use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class BlazePyTestConfigurationProducerTest method testProducedFromTestCaseWithParametersList.
@Test
public void testProducedFromTestCaseWithParametersList() throws Throwable {
PsiFile pyFile = createAndIndexFile(new WorkspacePath("py/test/unittest.py"), "class UnitTest(parameterized.TestCase):", " @parameterized.parameters([1,100])", " def testSomething(self, value):", " return");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("py_test").setLabel("//py/test:unittests").addSource(sourceRoot("py/test/unittest.py")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PyFunction function = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyFunction.class);
assertThat(function).isNotNull();
ConfigurationContext context = createContextFromPsi(function);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(TestContextRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTargets()).containsExactly(TargetExpression.fromStringSafe("//py/test:unittests"));
assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=\"UnitTest.testSomething0 UnitTest.testSomething1\"");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
assertThat(config.getName()).isEqualTo("Blaze test UnitTest.testSomething (unittest.py)");
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class BlazePyTestConfigurationProducerTest method testProducedFromTestCaseWithEmptyParametersList.
@Test
public void testProducedFromTestCaseWithEmptyParametersList() throws Throwable {
PsiFile pyFile = createAndIndexFile(new WorkspacePath("py/test/unittest.py"), "class UnitTest(parameterized.TestCase):", " @parameterized.parameters()", " def testSomething(self, value):", " return");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("py_test").setLabel("//py/test:unittests").addSource(sourceRoot("py/test/unittest.py")).build()).build());
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PyFunction function = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyFunction.class);
assertThat(function).isNotNull();
ConfigurationContext context = createContextFromPsi(function);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(TestContextRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTargets()).containsExactly(TargetExpression.fromStringSafe("//py/test:unittests"));
assertThat(getTestFilterContents(config)).isNull();
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
assertThat(config.getName()).isEqualTo("Blaze test UnitTest.testSomething (unittest.py)");
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class AllInBuildFileTestContextProviderTest method testProducedFromBuildFile.
@Test
public void testProducedFromBuildFile() {
setProjectView("directories:", " java/com/google/test", "targets:", " //java/com/google/test:lib");
PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
ConfigurationContext context = createContextFromPsi(buildFile);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(TestContextRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTargets()).containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:all"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class BlazeBuildFileRunConfigurationProducerTest method testProducedWhenInsideFuncallExpression.
@Test
public void testProducedWhenInsideFuncallExpression() {
PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
StringLiteral nameString = PsiUtils.findFirstChildOfClassRecursive(buildFile, StringLiteral.class);
assertThat(nameString).isNotNull();
ConfigurationContext context = createContextFromPsi(nameString);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeBuildFileRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTargets()).containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
use of com.intellij.execution.actions.ConfigurationFromContext in project intellij by bazelbuild.
the class BlazeBuildFileRunConfigurationProducerTest method testProducedFromFuncallExpression.
@Test
public void testProducedFromFuncallExpression() {
PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
FuncallExpression target = PsiUtils.findFirstChildOfClassRecursive(buildFile, FuncallExpression.class);
assertThat(target).isNotNull();
ConfigurationContext context = createContextFromPsi(target);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeBuildFileRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTargets()).containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
Aggregations