use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavaSyncTest method testTestSourcesUpdateCorrectlyOnSubsequentSync.
@Test
public void testTestSourcesUpdateCorrectlyOnSubsequentSync() {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib", "test_sources:", " java/com/google/tests/*");
VirtualFile root = workspace.createDirectory(new WorkspacePath("java/com/google"));
VirtualFile testsDir = workspace.createDirectory(new WorkspacePath("java/com/google/tests"));
VirtualFile moreTestsDir = workspace.createDirectory(new WorkspacePath("java/com/google/moretests"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ContentEntry contentEntry = findContentEntry(root);
assertThat(findSourceFolder(contentEntry, testsDir).isTestSource()).isTrue();
assertThat(findSourceFolder(contentEntry, moreTestsDir)).isNull();
// unmark one test source, mark another.
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib", "test_sources:", " java/com/google/moretests/*");
runBlazeSync(syncParams);
contentEntry = findContentEntry(root);
assertThat(findSourceFolder(contentEntry, testsDir)).isNull();
assertThat(findSourceFolder(contentEntry, moreTestsDir).isTestSource()).isTrue();
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavaSyncTest method testSimpleTestSourcesIdentified.
@Test
public void testSimpleTestSourcesIdentified() {
setProjectView("directories:", " java/com/google", " javatests/com/google", "targets:", " //java/com/google:lib", "test_sources:", " javatests/*");
VirtualFile javaRoot = workspace.createDirectory(new WorkspacePath("java/com/google"));
VirtualFile javatestsRoot = workspace.createDirectory(new WorkspacePath("javatests/com/google"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries();
assertThat(contentEntries).hasSize(2);
assertThat(findContentEntry(javaRoot)).isNotNull();
assertThat(findContentEntry(javaRoot).getSourceFolders()).hasLength(1);
assertThat(findContentEntry(javaRoot).getSourceFolders()[0].isTestSource()).isFalse();
assertThat(findContentEntry(javatestsRoot)).isNotNull();
assertThat(findContentEntry(javatestsRoot).getSourceFolders()).hasLength(1);
assertThat(findContentEntry(javatestsRoot).getSourceFolders()[0].isTestSource()).isTrue();
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavaSyncTest method testTestSourceRelativePackagePrefixCalculation.
@Test
public void testTestSourceRelativePackagePrefixCalculation() {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib", "test_sources:", " java/com/google/tests/*");
VirtualFile javatestsRoot = workspace.createDirectory(new WorkspacePath("java/com/google/tests"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ContentEntry root = findContentEntry(javatestsRoot.getParent());
SourceFolder rootSource = findSourceFolder(root, javatestsRoot.getParent());
assertThat(rootSource.isTestSource()).isFalse();
assertThat(rootSource.getPackagePrefix()).isEqualTo("com.google");
SourceFolder childTestSource = findSourceFolder(root, javatestsRoot);
assertThat(childTestSource.isTestSource()).isTrue();
assertThat(childTestSource.getPackagePrefix()).isEqualTo("com.google.tests");
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class KotlinSyncTest method testKotlinClassesPresentInClassPath.
@Test
public void testKotlinClassesPresentInClassPath() {
setProjectView("directories:", " src/main/kotlin/com/google", "targets:", " //src/main/kotlin/com/google:lib", "additional_languages:", " kotlin");
workspace.createFile(new WorkspacePath("src/main/kotlin/com/google/ClassWithUniqueName1.kt"), "package com.google;", "public class ClassWithUniqueName1 {}");
workspace.createFile(new WorkspacePath("src/main/kotlin/com/google/ClassWithUniqueName2.kt"), "package com.google;", "public class ClassWithUniqueName2 {}");
workspace.createDirectory(new WorkspacePath("external/com_github_jetbrains_kotlin"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("src/main/kotlin/com/google/BUILD")).setLabel("//src/main/kotlin/com/google:lib").setKind("kt_jvm_library").addSource(sourceRoot("src/main/kotlin/com/google/ClassWithUniqueName1.scala")).addSource(sourceRoot("src/main/kotlin/com/google/ClassWithUniqueName2.scala")).setJavaInfo(JavaIdeInfo.builder())).build();
setTargetMap(targetMap);
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
assertThat(blazeProjectData).isNotNull();
assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
assertThat(blazeProjectData.workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.JAVA, LanguageClass.KOTLIN)));
BlazeJavaSyncData javaSyncData = blazeProjectData.syncState.get(BlazeJavaSyncData.class);
assertThat(javaSyncData).isNotNull();
List<BlazeContentEntry> contentEntries = javaSyncData.importResult.contentEntries;
assertThat(contentEntries).hasSize(1);
BlazeContentEntry contentEntry = contentEntries.get(0);
assertThat(contentEntry.contentRoot.getPath()).isEqualTo(this.workspaceRoot.fileForPath(new WorkspacePath("src/main/kotlin/com/google")).getPath());
assertThat(contentEntry.sources).hasSize(1);
BlazeSourceDirectory sourceDir = contentEntry.sources.get(0);
assertThat(sourceDir.getPackagePrefix()).isEqualTo("com.google");
assertThat(sourceDir.getDirectory().getPath()).isEqualTo(this.workspaceRoot.fileForPath(new WorkspacePath("src/main/kotlin/com/google")).getPath());
}
use of com.google.idea.blaze.base.sync.BlazeSyncParams in project intellij by bazelbuild.
the class JavascriptSyncTest method testTestSourceChildrenAreNotAddedAsSourceFolders.
@Test
public void testTestSourceChildrenAreNotAddedAsSourceFolders() {
TestUtils.setPlatformPrefix(getTestRootDisposable(), PlatformUtils.IDEA_PREFIX);
// child directories of test sources are always test sources, so they should never
// appear as separate SourceFolders.
setProjectView("directories:", " common/jslayout", "targets:", " //common/jslayout/...:all", "test_sources:", " */tests/*", "workspace_type: javascript");
VirtualFile rootDir = workspace.createDirectory(new WorkspacePath("common/jslayout"));
VirtualFile nestedTestDir = workspace.createDirectory(new WorkspacePath("common/jslayout/tests/foo"));
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
errorCollector.assertNoIssues();
ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries();
assertThat(contentEntries).hasSize(1);
SourceFolder root = findSourceFolder(contentEntries.get(0), rootDir);
assertThat(root.isTestSource()).isFalse();
SourceFolder child = findSourceFolder(contentEntries.get(0), nestedTestDir);
assertThat(child).isNull();
SourceFolder testRoot = findSourceFolder(contentEntries.get(0), nestedTestDir.getParent());
assertThat(testRoot).isNotNull();
assertThat(testRoot.isTestSource()).isTrue();
}
Aggregations