use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BuildEventProtocolOutputReaderTest method parseTestResults_singleEvent_returnsTestResults.
@Test
public void parseTestResults_singleEvent_returnsTestResults() throws IOException {
Label label = Label.create("//java/com/google:unit_tests");
BuildEventStreamProtos.TestStatus status = BuildEventStreamProtos.TestStatus.FAILED;
ImmutableList<String> filePaths = ImmutableList.of("/usr/local/tmp/_cache/test_result.xml");
BuildEvent.Builder event = testResultEvent(label.toString(), status, filePaths);
BlazeTestResults results = BuildEventProtocolOutputReader.parseTestResults(asInputStream(event));
assertThat(results.perTargetResults.keySet()).containsExactly(label);
assertThat(results.perTargetResults.get(label)).hasSize(1);
BlazeTestResult result = results.perTargetResults.get(label).iterator().next();
assertThat(result.getTestStatus()).isEqualTo(TestStatus.FAILED);
assertThat(result.getOutputXmlFiles()).containsExactly(new File("/usr/local/tmp/_cache/test_result.xml"));
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BuildEventProtocolOutputReaderTest method parseTestResults_singleEvent_ignoresNonXmlOutputFiles.
@Test
public void parseTestResults_singleEvent_ignoresNonXmlOutputFiles() throws IOException {
Label label = Label.create("//java/com/google:unit_tests");
BuildEventStreamProtos.TestStatus status = BuildEventStreamProtos.TestStatus.FAILED;
ImmutableList<String> filePaths = ImmutableList.of("/usr/local/tmp/_cache/test_result.xml", "/usr/local/tmp/_cache/test_result.log", "/usr/local/tmp/other_output_file");
BuildEvent.Builder event = testResultEvent(label.toString(), status, filePaths);
BlazeTestResults results = BuildEventProtocolOutputReader.parseTestResults(asInputStream(event));
BlazeTestResult result = results.perTargetResults.get(label).iterator().next();
assertThat(result.getOutputXmlFiles()).containsExactly(new File("/usr/local/tmp/_cache/test_result.xml"));
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazePyRunConfigurationRunnerTest method testMultipleOutputFiles.
@Test
public void testMultipleOutputFiles() {
Label target = Label.create("//path/to/package:SomeTest");
ImmutableList<File> outputFiles = ImmutableList.of(new File("blaze-bin/path/to/package/SomeTest.run.py"), new File("blaze-bin/path/to/package/SomeTest"));
assertThat(BlazePyRunConfigurationRunner.findExecutable(target, outputFiles)).isEqualTo(new File("blaze-bin/path/to/package/SomeTest"));
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazeRenderErrorContributorTest method createTargetMapWithNonStandardAndroidManifestName.
private void createTargetMapWithNonStandardAndroidManifestName() {
Label mainResourceTarget = Label.create("//com/google/example:main");
ArtifactLocation mainManifest = artifact("com/google/example/main/WeirdManifest.xml", true);
ArtifactLocation mainResource = artifact("com/google/example/main/res", true);
ArtifactLocation mainBuildFile = artifact("com/google/example/main/BUILD", true);
AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
registry.put(module, AndroidResourceModule.builder(TargetKey.forPlainTarget(mainResourceTarget)).addResource(mainResource).build());
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(mainResourceTarget).setBuildFile(mainBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).setManifestFile(mainManifest).addResource(mainResource))).build();
projectDataManager.setTargetMap(targetMap);
}
use of com.google.idea.blaze.base.model.primitives.Label in project intellij by bazelbuild.
the class BlazeRenderErrorContributorTest method createTargetMapWithGeneratedResources.
private void createTargetMapWithGeneratedResources() {
Label mainResourcesTarget = Label.create("//com/google/example:main");
Label dependencyGeneratedResourceTarget = Label.create("//com/google/example:generated");
Label dependencySourceResourceTarget = Label.create("//com/google/example:source");
Label transitiveGeneratedResourcesTarget = Label.create("//com/google/example/transitive:generated");
Label transitiveSourceResourceTarget = Label.create("//com/google/example/transitive:source");
Label unrelatedGeneratedResourceTarget = Label.create("//com/google/unrelated:generated");
Label unrelatedSourceResourceTarget = Label.create("//com/google/unrelated:source");
ArtifactLocation mainGeneratedResource = artifact("com/google/example/main/generated/res", false);
ArtifactLocation mainSourceResource = artifact("com/google/example/main/source/res", true);
ArtifactLocation dependencyGeneratedResource = artifact("com/google/example/dependency/generated/res", false);
ArtifactLocation dependencySourceResource = artifact("com/google/example/dependency/source/res", true);
ArtifactLocation transitiveGeneratedResourceOne = artifact("com/google/example/transitive/generated/one/res", false);
ArtifactLocation transitiveGeneratedResourceTwo = artifact("com/google/example/transitive/generated/two/res", false);
ArtifactLocation transitiveSourceResource = artifact("com/google/example/transitive/source/res", true);
ArtifactLocation unrelatedGeneratedResource = artifact("com/google/unrelated/generated/res", false);
ArtifactLocation unrelatedSourceResource = artifact("com/google/unrelated/source/res", true);
ArtifactLocation mainBuildFile = artifact("com/google/example/main/BUILD", true);
ArtifactLocation dependencyBuildFile = artifact("com/google/example/dependency/BUILD", true);
ArtifactLocation transitiveBuildFile = artifact("com/google/example/transitive/BUILD", true);
ArtifactLocation unrelatedBuildFile = artifact("com/google/unrelated/BUILD", true);
AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
registry.put(module, AndroidResourceModule.builder(TargetKey.forPlainTarget(mainResourcesTarget)).addResource(mainSourceResource).addTransitiveResourceDependency(dependencyGeneratedResourceTarget).addTransitiveResource(dependencyGeneratedResource).addTransitiveResourceDependency(dependencySourceResourceTarget).addTransitiveResource(dependencySourceResource).addTransitiveResourceDependency(transitiveGeneratedResourcesTarget).addTransitiveResource(transitiveGeneratedResourceOne).addTransitiveResource(transitiveGeneratedResourceTwo).addTransitiveResourceDependency(transitiveSourceResourceTarget).addTransitiveResource(transitiveSourceResource).build());
// Not using these, but they should be in the registry.
registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(dependencyGeneratedResourceTarget)).addTransitiveResourceDependency(transitiveSourceResourceTarget).addTransitiveResource(transitiveSourceResource).build());
registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(dependencySourceResourceTarget)).addResource(dependencySourceResource).addTransitiveResourceDependency(transitiveGeneratedResourcesTarget).addTransitiveResource(transitiveGeneratedResourceOne).addTransitiveResource(transitiveGeneratedResourceTwo).build());
registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(transitiveGeneratedResourcesTarget)).build());
registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(transitiveSourceResourceTarget)).addResource(transitiveSourceResource).build());
registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(unrelatedGeneratedResourceTarget)).build());
registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(unrelatedSourceResourceTarget)).addResource(unrelatedSourceResource).build());
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(mainResourcesTarget).setBuildFile(mainBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(mainGeneratedResource).addResource(mainSourceResource)).addDependency(dependencyGeneratedResourceTarget).addDependency(dependencySourceResourceTarget)).addTarget(TargetIdeInfo.builder().setLabel(dependencyGeneratedResourceTarget).setBuildFile(dependencyBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(dependencyGeneratedResource)).addDependency(transitiveSourceResourceTarget)).addTarget(TargetIdeInfo.builder().setLabel(dependencySourceResourceTarget).setBuildFile(dependencyBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(dependencySourceResource)).addDependency(transitiveGeneratedResourcesTarget)).addTarget(TargetIdeInfo.builder().setLabel(transitiveGeneratedResourcesTarget).setBuildFile(transitiveBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(transitiveGeneratedResourceOne).addResource(transitiveGeneratedResourceTwo))).addTarget(TargetIdeInfo.builder().setLabel(transitiveSourceResourceTarget).setBuildFile(transitiveBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(transitiveSourceResource))).addTarget(TargetIdeInfo.builder().setLabel(unrelatedGeneratedResourceTarget).setBuildFile(unrelatedBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(unrelatedGeneratedResource))).addTarget(TargetIdeInfo.builder().setLabel(unrelatedSourceResourceTarget).setBuildFile(unrelatedBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(unrelatedSourceResource))).build();
projectDataManager.setTargetMap(targetMap);
}
Aggregations