Search in sources :

Example 11 with TargetInfo

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

the class TestSizeHeuristicTest method testPredicateDifferentSize.

@Test
public void testPredicateDifferentSize() 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.SMALL)).isFalse();
}
Also used : TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 12 with TargetInfo

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

the class TestTargetSourcesHeuristicTest method testFilterNoMatchesFallBackToFirstRule.

@Test
public void testFilterNoMatchesFallBackToFirstRule() throws Exception {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    ImmutableList<TargetInfo> rules = 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").build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, rules, null);
    assertThat(match.label).isEqualTo(Label.create("//foo:test1"));
}
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 13 with TargetInfo

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

the class TestTargetSourcesHeuristicTest method testPredicateNoMatchingSource.

@Test
public void testPredicateNoMatchingSource() {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:test").setKind("java_test").addSource(sourceRoot("java/com/bar/OtherTest.java")).build().toTargetInfo();
    assertThat(new TestTargetSourcesHeuristic().matchesSource(project, target, null, source, null)).isFalse();
}
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 14 with TargetInfo

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

the class TestTargetSourcesHeuristicTest method testFilterOneMatch.

@Test
public void testFilterOneMatch() throws Exception {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    ImmutableList<TargetInfo> rules = 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(project, null, source, rules, 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 15 with TargetInfo

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

the class TestTargetSourcesHeuristicTest method testPredicateNoSources.

@Test
public void testPredicateNoSources() {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:test").setKind("java_test").build().toTargetInfo();
    assertThat(new TestTargetSourcesHeuristic().matchesSource(project, target, null, source, null)).isFalse();
}
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)

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