use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ProjectViewParserTest method testMultipleSections.
@Test
public void testMultipleSections() throws Exception {
projectViewStorageManager.add(".blazeproject", "directories:", " java/com/google", "directories:", " java/com/google2", "", "workspace_type: java", "workspace_type: android");
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
assertThat(projectViewSet.listItems(DirectorySection.KEY)).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google2"), true));
assertThat(projectViewSet.listScalarItems(WorkspaceTypeSection.KEY)).containsExactly(WorkspaceType.JAVA, WorkspaceType.ANDROID);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ProjectViewParserTest method testListParserAcceptsWhitespace.
@Test
public void testListParserAcceptsWhitespace() throws Exception {
String text = Joiner.on('\n').join("directories:", " dir0", " ", "", " dir1", " ", " ", "# comment", " dir2", "", " # commented out dir", " ", "# comment", "# comment");
projectViewStorageManager.add(".blazeproject", text);
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
assert projectViewFile != null;
ProjectView projectView = projectViewFile.projectView;
assertThat(projectView).isEqualTo(ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("dir0"))).add(TextBlock.of(" ")).add(TextBlock.of("")).add(DirectoryEntry.include(new WorkspacePath("dir1"))).add(TextBlock.of(" ", " ")).add(TextBlock.of("# comment")).add(DirectoryEntry.include(new WorkspacePath("dir2"))).add(TextBlock.of("")).add(TextBlock.of(" # commented out dir")).add(TextBlock.of(" "))).add(TextBlockSection.of(TextBlock.of("# comment", "# comment"))).build());
String outputString = ProjectViewParser.projectViewToString(projectView);
assertThat(outputString).isEqualTo(text);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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"));
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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();
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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"));
}
Aggregations