Search in sources :

Example 56 with TargetInfo

use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.

the class TestTargetHeuristicTest method testTargetSourcesCheckedBeforeTestSize.

@Test
public void testTargetSourcesCheckedBeforeTestSize() {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    Collection<TargetInfo> targets = ImmutableList.of(TargetIdeInfo.builder().setLabel("//foo:test1").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.SMALL)).addSource(sourceRoot("java/com/bar/OtherTest.java")).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test2").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.MEDIUM)).addSource(sourceRoot("java/com/foo/FooTest.java")).build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(getProject(), null, source, targets, TestSize.SMALL);
    assertThat(match.label).isEqualTo(Label.create("//foo:test2"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 57 with TargetInfo

use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.

the class TestTargetHeuristicTest method testTargetSourcesMatched.

@Test
public void testTargetSourcesMatched() {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    Collection<TargetInfo> targets = ImmutableList.of(TargetIdeInfo.builder().setLabel("//foo:test1").setKind("java_test").addSource(sourceRoot("java/com/bar/OtherTest.java")).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test2").setKind("java_test").addSource(sourceRoot("java/com/foo/FooTest.java")).build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(getProject(), null, source, targets, null);
    assertThat(match.label).isEqualTo(Label.create("//foo:test2"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 58 with TargetInfo

use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.

the class TestTargetHeuristicTest method testTargetNameCheckedBeforeTestSize.

@Test
public void testTargetNameCheckedBeforeTestSize() {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    ImmutableList<TargetInfo> targets = ImmutableList.of(TargetIdeInfo.builder().setLabel("//bar:BarTest").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.SMALL)).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:FooTest").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.MEDIUM)).build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(getProject(), null, source, targets, TestSize.SMALL);
    assertThat(match.label).isEqualTo(Label.create("//foo:FooTest"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 59 with TargetInfo

use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.

the class RuleNameHeuristicTest method testFilterOneMatch.

@Test
public void testFilterOneMatch() throws Exception {
    File source = new File("java/com/foo/FooTest.java");
    Collection<TargetInfo> targets = ImmutableList.of(TargetIdeInfo.builder().setLabel("//bar:FirstTest").setKind("java_test").build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:FooTest").setKind("java_test").build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, targets, null);
    assertThat(match.label).isEqualTo(Label.create("//foo:FooTest"));
}
Also used : TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 60 with TargetInfo

use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.

the class RuleNameHeuristicTest method testPredicateMatchingName.

@Test
public void testPredicateMatchingName() throws Exception {
    File source = new File("java/com/foo/FooTest.java");
    TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:FooTest").setKind("java_test").build().toTargetInfo();
    assertThat(new TargetNameHeuristic().matchesSource(project, target, null, source, null)).isTrue();
}
Also used : TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Aggregations

TargetInfo (com.google.idea.blaze.base.dependencies.TargetInfo)69 File (java.io.File)43 Test (org.junit.Test)40 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)19 PsiFile (com.intellij.psi.PsiFile)18 Nullable (javax.annotation.Nullable)15 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)14 PsiElement (com.intellij.psi.PsiElement)9 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)7 Label (com.google.idea.blaze.base.model.primitives.Label)7 PsiClass (com.intellij.psi.PsiClass)7 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)6 RuleType (com.google.idea.blaze.base.model.primitives.RuleType)6 BlazeProjectDataManager (com.google.idea.blaze.base.sync.data.BlazeProjectDataManager)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)5 BlazeTestCase (com.google.idea.blaze.base.BlazeTestCase)5 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)5 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)5 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)5