Search in sources :

Example 6 with ParsedBepOutput

use of com.google.idea.blaze.base.command.buildresult.ParsedBepOutput in project intellij by bazelbuild.

the class FullApkBuildStepIntegrationTest method build_withNullExecRoot_shouldFail.

@Test
public void build_withNullExecRoot_shouldFail() throws Exception {
    // Return null execroot
    when(mockBuildResultHelper.getBuildOutput()).thenReturn(new ParsedBepOutput(null, null, null, null, 0, BuildResult.SUCCESS));
    // Return fake deploy info proto and mocked deploy info data object.
    AndroidDeployInfo fakeProto = AndroidDeployInfo.newBuilder().build();
    BlazeAndroidDeployInfo mockDeployInfo = mock(BlazeAndroidDeployInfo.class);
    when(mockDeployInfo.getApksToDeploy()).thenReturn(ImmutableList.of());
    BlazeApkDeployInfoProtoHelper helper = mock(BlazeApkDeployInfoProtoHelper.class);
    when(helper.readDeployInfoProtoForTarget(eq(buildTarget), any(BuildResultHelper.class), any())).thenReturn(fakeProto);
    when(helper.extractDeployInfoAndInvalidateManifests(eq(getProject()), eq(new File(getExecRoot())), eq(fakeProto))).thenReturn(mockDeployInfo);
    // Perform
    FullApkBuildStep buildStep = new FullApkBuildStep(getProject(), buildTarget, blazeFlags, helper);
    buildStep.build(context, new DeviceSession(null, null, null));
    // Verify
    assertThat(context.hasErrors()).isTrue();
    assertThat(messageCollector.getMessages()).contains("Could not locate execroot!");
}
Also used : FullApkBuildStep(com.google.idea.blaze.android.run.runner.FullApkBuildStep) AndroidDeployInfo(com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.AndroidDeployInfo) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) BuildResultHelper(com.google.idea.blaze.base.command.buildresult.BuildResultHelper) BlazeApkDeployInfoProtoHelper(com.google.idea.blaze.android.run.deployinfo.BlazeApkDeployInfoProtoHelper) DeviceSession(com.google.idea.blaze.android.run.runner.BlazeAndroidDeviceSelector.DeviceSession) BlazeAndroidDeployInfo(com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo) ParsedBepOutput(com.google.idea.blaze.base.command.buildresult.ParsedBepOutput) File(java.io.File) Test(org.junit.Test)

Example 7 with ParsedBepOutput

use of com.google.idea.blaze.base.command.buildresult.ParsedBepOutput in project intellij by bazelbuild.

the class FullApkBuildStepIntegrationTest method setupBuildResultHelperProvider.

/**
 * Setup build result helper to return BEP output with test execroot by default.
 */
@Before
public void setupBuildResultHelperProvider() throws GetArtifactsException {
    mockBuildResultHelper = mock(BuildResultHelper.class);
    when(mockBuildResultHelper.getBuildOutput()).thenReturn(new ParsedBepOutput(null, getExecRoot(), null, null, 0, BuildResult.SUCCESS));
    registerExtension(BuildResultHelperProvider.EP_NAME, new BuildResultHelperProvider() {

        @Override
        public Optional<BuildResultHelper> doCreate(Project project, BlazeInfo blazeInfo) {
            return Optional.of(mockBuildResultHelper);
        }

        @Override
        public Optional<BuildResultHelper> doCreateForLocalBuild(Project project) {
            return Optional.of(mockBuildResultHelper);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) BuildResultHelper(com.google.idea.blaze.base.command.buildresult.BuildResultHelper) Optional(java.util.Optional) BuildResultHelperProvider(com.google.idea.blaze.base.command.buildresult.BuildResultHelperProvider) ParsedBepOutput(com.google.idea.blaze.base.command.buildresult.ParsedBepOutput) Before(org.junit.Before)

Aggregations

ParsedBepOutput (com.google.idea.blaze.base.command.buildresult.ParsedBepOutput)7 BuildResultHelper (com.google.idea.blaze.base.command.buildresult.BuildResultHelper)6 File (java.io.File)4 AndroidDeployInfo (com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.AndroidDeployInfo)3 BlazeAndroidDeployInfo (com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo)3 BlazeApkDeployInfoProtoHelper (com.google.idea.blaze.android.run.deployinfo.BlazeApkDeployInfoProtoHelper)3 DeviceSession (com.google.idea.blaze.android.run.runner.BlazeAndroidDeviceSelector.DeviceSession)3 BuildResultHelperProvider (com.google.idea.blaze.base.command.buildresult.BuildResultHelperProvider)3 BlazeInfo (com.google.idea.blaze.base.command.info.BlazeInfo)3 Project (com.intellij.openapi.project.Project)3 Optional (java.util.Optional)3 Before (org.junit.Before)3 Test (org.junit.Test)3 DeviceFutures (com.android.tools.idea.run.DeviceFutures)1 MessageCollector (com.google.idea.blaze.android.MessageCollector)1 MobileInstallBuildStep (com.google.idea.blaze.android.run.binary.mobileinstall.MobileInstallBuildStep)1 BlazeInstrumentationTestApkBuildStep (com.google.idea.blaze.android.run.runner.BlazeInstrumentationTestApkBuildStep)1 FullApkBuildStep (com.google.idea.blaze.android.run.runner.FullApkBuildStep)1 GetArtifactsException (com.google.idea.blaze.base.command.buildresult.BuildResultHelper.GetArtifactsException)1 OutputArtifact (com.google.idea.blaze.base.command.buildresult.OutputArtifact)1