Search in sources :

Example 61 with TargetInfo

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

the class RuleNameHeuristicTest method testPredicateMatchingNameAndPath.

@Test
public void testPredicateMatchingNameAndPath() throws Exception {
    File source = new File("java/com/foo/FooTest.java");
    TargetInfo target = TargetIdeInfo.builder().setLabel("//foo: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)

Example 62 with TargetInfo

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

the class RuleNameHeuristicTest method testFilterNoMatchesFallBackToFirstRule.

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

Example 63 with TargetInfo

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

the class RuleNameHeuristicTest method testPredicateDifferentName.

@Test
public void testPredicateDifferentName() throws Exception {
    File source = new File("java/com/foo/FooTest.java");
    TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:ForTest").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 64 with TargetInfo

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

the class TestSizeHeuristicTest method testPredicateMatchingSize.

@Test
public void testPredicateMatchingSize() 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.MEDIUM)).build().toTargetInfo();
    assertThat(new TestSizeHeuristic().matchesSource(project, target, null, source, TestSize.MEDIUM)).isTrue();
}
Also used : TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 65 with TargetInfo

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

the class TestSizeHeuristicTest method testFilterNoMatchesFallBackToFirstRule.

@Test
public void testFilterNoMatchesFallBackToFirstRule() 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.LARGE)).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test3").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.ENORMOUS)).build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, rules, TestSize.SMALL);
    assertThat(match.label).isEqualTo(Label.create("//foo:test1"));
}
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