use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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();
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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();
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ImportRootsTest method testNoAddedExclusionsWithoutWorkspaceRootInclusion.
@Test
public void testNoAddedExclusionsWithoutWorkspaceRootInclusion() {
ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Bazel).add(new DirectoryEntry(new WorkspacePath("foo/bar"), true)).build();
assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath("foo/bar"));
assertThat(importRoots.excludeDirectories()).isEmpty();
}
Aggregations