use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class TestSizeHeuristicTest method testFilterOneMatch.
@Test
public void testFilterOneMatch() 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());
TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, rules, TestSize.SMALL);
assertThat(match.label).isEqualTo(Label.create("//foo:test2"));
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class TestTargetSourcesHeuristicTest method testPredicateMatchingSource.
@Test
public void testPredicateMatchingSource() {
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")).addSource(sourceRoot("java/com/foo/FooTest.java")).build().toTargetInfo();
assertThat(new TestTargetSourcesHeuristic().matchesSource(project, target, null, source, null)).isTrue();
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class TestMapTest method testTrivialTestMap.
@Test
public void testTrivialTestMap() throws Exception {
mockBlazeProjectDataManager.targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//test:test").setKind("java_test").addSource(sourceRoot("test/Test.java"))).build();
Collection<TargetInfo> targets = SourceToTargetFinder.findTargetsForSourceFile(project, new File("/test/Test.java"), Optional.of(RuleType.TEST));
assertThat(targets.stream().map(t -> t.label).collect(Collectors.toList())).containsExactly(Label.create("//test:test"));
}
use of com.google.idea.blaze.base.dependencies.TargetInfo in project intellij by bazelbuild.
the class TestMapTest method testBfsPreferred.
@Test
public void testBfsPreferred() throws Exception {
mockBlazeProjectDataManager.targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//test:lib").setKind("java_library").addSource(sourceRoot("test/Test.java"))).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//test:lib2").setKind("java_library").addDependency("//test:lib")).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//test:test2").setKind("java_test").addDependency("//test:lib2")).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("test/BUILD")).setLabel("//test:test").setKind("java_test").addDependency("//test:lib")).build();
Collection<TargetInfo> targets = SourceToTargetFinder.findTargetsForSourceFile(project, new File("/test/Test.java"), Optional.of(RuleType.TEST));
assertThat(targets.stream().map(t -> t.label).collect(Collectors.toList())).containsExactly(Label.create("//test:test"), Label.create("//test:test2")).inOrder();
}
Aggregations