Search in sources :

Example 11 with Label

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"));
}
Also used : BuildEventStreamProtos(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos) BlazeTestResult(com.google.idea.blaze.base.run.testlogs.BlazeTestResult) BuildEvent(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent) Label(com.google.idea.blaze.base.model.primitives.Label) BlazeTestResults(com.google.idea.blaze.base.run.testlogs.BlazeTestResults) File(java.io.File) Test(org.junit.Test)

Example 12 with Label

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"));
}
Also used : BuildEventStreamProtos(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos) BlazeTestResult(com.google.idea.blaze.base.run.testlogs.BlazeTestResult) BuildEvent(com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent) Label(com.google.idea.blaze.base.model.primitives.Label) BlazeTestResults(com.google.idea.blaze.base.run.testlogs.BlazeTestResults) File(java.io.File) Test(org.junit.Test)

Example 13 with Label

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"));
}
Also used : Label(com.google.idea.blaze.base.model.primitives.Label) File(java.io.File) Test(org.junit.Test)

Example 14 with Label

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);
}
Also used : Label(com.google.idea.blaze.base.model.primitives.Label) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Example 15 with Label

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);
}
Also used : Label(com.google.idea.blaze.base.model.primitives.Label) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) MockModule(com.intellij.mock.MockModule) Module(com.intellij.openapi.module.Module) AndroidResourceModule(com.google.idea.blaze.android.sync.model.AndroidResourceModule) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Aggregations

Label (com.google.idea.blaze.base.model.primitives.Label)48 File (java.io.File)15 Test (org.junit.Test)11 Nullable (javax.annotation.Nullable)8 BlazeTestResults (com.google.idea.blaze.base.run.testlogs.BlazeTestResults)7 BuildEventStreamProtos (com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos)6 BlazeTestResult (com.google.idea.blaze.base.run.testlogs.BlazeTestResult)6 AndroidResourceModuleRegistry (com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry)5 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)5 Kind (com.google.idea.blaze.base.model.primitives.Kind)5 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)5 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)4 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)4 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)4 BuildEvent (com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent)3 AndroidResourceModule (com.google.idea.blaze.android.sync.model.AndroidResourceModule)3 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)3 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)3 StatusOutput (com.google.idea.blaze.base.scope.output.StatusOutput)3 SourceToTargetMap (com.google.idea.blaze.base.targetmaps.SourceToTargetMap)3