Search in sources :

Example 6 with TargetInfo

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

the class RuleNameHeuristicTest method testPredicateNotMatchingForPartialOverlap.

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

Example 7 with TargetInfo

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

the class RuleNameHeuristicTest method testFilterChoosesFirstMatch.

@Test
public void testFilterChoosesFirstMatch() throws Exception {
    File source = new File("java/com/foo/FooTest.java");
    Collection<TargetInfo> targets = ImmutableList.of(TargetIdeInfo.builder().setLabel("//bar:OtherTest").setKind("java_test").build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:FooTest").setKind("java_test").build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//bar/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 8 with TargetInfo

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

the class RuleNameHeuristicTest method testPredicateNotMatchingIncorrectPath.

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

Example 9 with TargetInfo

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

the class TestSizeHeuristicTest method testPredicateDefaultToSmallSize.

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

Example 10 with TargetInfo

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

the class TestSizeHeuristicTest method testFilterChoosesFirstMatch.

@Test
public void testFilterChoosesFirstMatch() throws Exception {
    File source = new File("java/com/foo/FooTest.java");
    ImmutableList<TargetInfo> rules = ImmutableList.of(TargetIdeInfo.builder().setLabel("//foo:test1").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.MEDIUM)).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test2").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.SMALL)).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test3").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.SMALL)).build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, rules, TestSize.SMALL);
    assertThat(match.label).isEqualTo(Label.create("//foo:test2"));
}
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