Search in sources :

Example 6 with BlazeRunConfiguration

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

the class BlazeJavaMainClassConfigurationProducerTest method testUniqueJavaBinaryChosen.

@Test
public void testUniqueJavaBinaryChosen() {
    MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
    builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("java_binary").setLabel("//com/google/binary:UnrelatedName").addSource(sourceRoot("com/google/binary/MainClass.java")).build()).build());
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
    PsiFile javaClass = createAndIndexFile(WorkspacePath.createIfValid("com/google/binary/MainClass.java"), "package com.google.binary;", "import java.lang.String;", "public class MainClass {", "  public static void main(java.lang.String[] args) {}", "}");
    RunConfiguration config = createConfigurationFromLocation(javaClass);
    assertThat(config).isInstanceOf(BlazeRunConfiguration.class);
    BlazeRunConfiguration blazeConfig = (BlazeRunConfiguration) config;
    assertThat(blazeConfig.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//com/google/binary:UnrelatedName"));
}
Also used : BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) PsiFile(com.intellij.psi.PsiFile) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Example 7 with BlazeRunConfiguration

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

the class BlazeJavaMainClassConfigurationProducerTest method testJavaBinaryWithMatchingNameChosen.

@Test
public void testJavaBinaryWithMatchingNameChosen() {
    MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
    builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("java_binary").setLabel("//com/google/binary:UnrelatedName").addSource(sourceRoot("com/google/binary/MainClass.java")).build()).addTarget(TargetIdeInfo.builder().setKind("java_binary").setLabel("//com/google/binary:MainClass").addSource(sourceRoot("com/google/binary/MainClass.java")).build()).build());
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
    PsiFile javaClass = createAndIndexFile(WorkspacePath.createIfValid("com/google/binary/MainClass.java"), "package com.google.binary;", "import java.lang.String;", "public class MainClass {", "  public static void main(java.lang.String[] args) {}", "}");
    RunConfiguration config = createConfigurationFromLocation(javaClass);
    assertThat(config).isInstanceOf(BlazeRunConfiguration.class);
    BlazeRunConfiguration blazeConfig = (BlazeRunConfiguration) config;
    assertThat(blazeConfig.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//com/google/binary:MainClass"));
}
Also used : BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) PsiFile(com.intellij.psi.PsiFile) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Example 8 with BlazeRunConfiguration

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

the class BlazeScalaMainClassConfigurationProducerTest method testUniqueScalaBinaryChosen.

@Test
public void testUniqueScalaBinaryChosen() {
    MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
    builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("scala_binary").setLabel("//com/google/binary:UnrelatedName").addSource(sourceRoot("com/google/binary/MainClass.scala")).build()).build());
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
    PsiFile scalaFile = createAndIndexFile(WorkspacePath.createIfValid("com/google/binary/MainClass.scala"), "package com.google.binary {", "  object MainClass {", "    def main(args: Array[String]) {}", "  }", "}", "package scala { final class Array[T] {} }", "package java.lang { public final class String {} }");
    RunConfiguration config = createConfigurationFromLocation(scalaFile);
    assertThat(config).isInstanceOf(BlazeRunConfiguration.class);
    BlazeRunConfiguration blazeConfig = (BlazeRunConfiguration) config;
    assertThat(blazeConfig).isNotNull();
    assertThat(blazeConfig.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//com/google/binary:UnrelatedName"));
}
Also used : BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeRunConfiguration(com.google.idea.blaze.base.run.BlazeRunConfiguration) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) PsiFile(com.intellij.psi.PsiFile) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Aggregations

BlazeRunConfiguration (com.google.idea.blaze.base.run.BlazeRunConfiguration)8 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)8 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)6 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)6 PsiFile (com.intellij.psi.PsiFile)6 Test (org.junit.Test)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2