use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ProjectViewLabelReferenceTest method testDirectoryReference.
@Test
public void testDirectoryReference() {
PsiDirectory directory = workspace.createPsiDirectory(new WorkspacePath("foo/bar"));
PsiFile projectView = workspace.createPsiFile(new WorkspacePath(".bazelproject"), "directories:", " foo/bar");
ProjectViewPsiSectionItem importItem = PsiUtils.findFirstChildOfClassRecursive(projectView, ProjectViewPsiSectionItem.class);
assertThat(importItem).isNotNull();
assertThat(importItem.getReference().resolve()).isEqualTo(directory);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class ProjectViewLabelReferenceTest method testFileReference.
@Test
public void testFileReference() {
PsiFile referencedFile = workspace.createPsiFile(new WorkspacePath("ijwb.bazelproject"), "directories:", " java/com/google/foo", "targets:", " //java/com/google/foo/...");
PsiFile file = workspace.createPsiFile(new WorkspacePath(".bazelproject"), "import ijwb.bazelproject");
ProjectViewPsiSectionItem importItem = PsiUtils.findFirstChildOfClassRecursive(file, ProjectViewPsiSectionItem.class);
assertThat(importItem).isNotNull();
assertThat(importItem.getReference().resolve()).isEqualTo(referencedFile);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class TestTargetHeuristicTest method testNoMatchFallBackToFirstTarget.
@Test
public void testNoMatchFallBackToFirstTarget() {
File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
ImmutableList<TargetInfo> targets = ImmutableList.of(TargetIdeInfo.builder().setLabel("//bar:BarTest").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.MEDIUM)).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:OtherTest").setKind("java_test").setTestInfo(TestIdeInfo.builder().setTestSize(TestSize.SMALL)).build().toTargetInfo());
TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(getProject(), null, source, targets, TestSize.LARGE);
assertThat(match.label).isEqualTo(Label.create("//bar:BarTest"));
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class RunConfigurationSerializerTest method testConvertAbsolutePathToWorkspacePathVariableWhenSerializing.
@Test
public void testConvertAbsolutePathToWorkspacePathVariableWhenSerializing() {
if (isAndroidStudio()) {
// #api171: disable for android studio -- path variable substitution isn't working in 2017.1
return;
}
WorkspacePath binaryPath = WorkspacePath.createIfValid("path/to/binary/blaze");
String absoluteBinaryPath = workspaceRoot.fileForPath(binaryPath).getPath();
setBlazeBinaryPath(configuration, absoluteBinaryPath);
Element element = RunConfigurationSerializer.writeToXml(configuration);
assertThat(element.getAttribute("blaze-binary").getValue()).isEqualTo(String.format("$%s$/%s", RunConfigurationSerializer.WORKSPACE_ROOT_VARIABLE_NAME, binaryPath));
// remove configuration from project
clearRunManager();
RunConfigurationSerializer.loadFromXmlElementIgnoreExisting(getProject(), element);
RunConfiguration config = runManager.getAllConfigurations()[0];
assertThat(config).isInstanceOf(BlazeCommandRunConfiguration.class);
assertThat(getBlazeBinaryPath((BlazeCommandRunConfiguration) config)).isEqualTo(absoluteBinaryPath);
}
use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.
the class AllInPackageBlazeConfigurationProducerTest method testDirectoryWithoutBlazePackageChildIsIgnored.
@Test
public void testDirectoryWithoutBlazePackageChildIsIgnored() {
PsiDirectory directory = workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
ConfigurationContext context = createContextFromPsi(directory);
AllInPackageBlazeConfigurationProducer producer = new AllInPackageBlazeConfigurationProducer();
assertThat(producer.createConfigurationFromContext(context)).isNull();
workspace.createPsiDirectory(new WorkspacePath("java/com/google/test/child_dir"));
workspace.createPsiFile(new WorkspacePath("java/com/google/test/child_dir/BUILD"));
assertThat(producer.createConfigurationFromContext(context)).isNotNull();
}
Aggregations