Search in sources :

Example 1 with BlazeBuildFileRunConfigurationProducer

use of com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer in project intellij by bazelbuild.

the class BlazeBuildFileRunConfigurationProducerTest method testConfigWithTestFilterIgnored.

@Test
public void testConfigWithTestFilterIgnored() {
    PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
    StringLiteral nameString = PsiUtils.findFirstChildOfClassRecursive(buildFile, StringLiteral.class);
    ConfigurationContext context = createContextFromPsi(nameString);
    BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) context.getConfiguration().getConfiguration();
    BlazeCommandRunConfigurationCommonState handlerState = config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
    handlerState.getBlazeFlagsState().setRawFlags(ImmutableList.of(BlazeFlags.TEST_FILTER + "=com.google.test.SingleTestClass#"));
    assertThat(new BlazeBuildFileRunConfigurationProducer().isConfigurationFromContext(config, context)).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) BlazeBuildFileRunConfigurationProducer(com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Example 2 with BlazeBuildFileRunConfigurationProducer

use of com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer in project intellij by bazelbuild.

the class BlazeBuildFileRunConfigurationProducerTest method testConfigFromContextRecognizesItsOwnConfig.

@Test
public void testConfigFromContextRecognizesItsOwnConfig() {
    PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
    StringLiteral nameString = PsiUtils.findFirstChildOfClassRecursive(buildFile, StringLiteral.class);
    ConfigurationContext context = createContextFromPsi(nameString);
    BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) context.getConfiguration().getConfiguration();
    assertThat(new BlazeBuildFileRunConfigurationProducer().isConfigurationFromContext(config, context)).isTrue();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeBuildFileRunConfigurationProducer(com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Example 3 with BlazeBuildFileRunConfigurationProducer

use of com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer in project intellij by bazelbuild.

the class BlazeBuildFileRunConfigurationProducerTest method testConfigWithDifferentLabelIgnored.

@Test
public void testConfigWithDifferentLabelIgnored() {
    PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
    StringLiteral nameString = PsiUtils.findFirstChildOfClassRecursive(buildFile, StringLiteral.class);
    ConfigurationContext context = createContextFromPsi(nameString);
    BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) context.getConfiguration().getConfiguration();
    // modify the label, and check that is enough for the producer to class it as different.
    config.setTarget(Label.create("//java/com/google/test:integration_tests"));
    assertThat(new BlazeBuildFileRunConfigurationProducer().isConfigurationFromContext(config, context)).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeBuildFileRunConfigurationProducer(com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) PsiFile(com.intellij.psi.PsiFile) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Test(org.junit.Test)

Aggregations

StringLiteral (com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)3 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)3 BlazeBuildFileRunConfigurationProducer (com.google.idea.blaze.base.run.producers.BlazeBuildFileRunConfigurationProducer)3 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)3 PsiFile (com.intellij.psi.PsiFile)3 Test (org.junit.Test)3 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)1