Search in sources :

Example 6 with FullApkBuildStep

use of com.google.idea.blaze.android.run.runner.FullApkBuildStep in project intellij by bazelbuild.

the class FullApkBuildStepIntegrationTest method build_withBlazeCommandFailure_shouldFail.

@Test
public void build_withBlazeCommandFailure_shouldFail() throws Exception {
    // Return a non-zero value to indicate blaze command run failure.
    registerApplicationService(ExternalTaskProvider.class, builder -> scopes -> 1337);
    // 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, ImmutableList.of(), helper);
    buildStep.build(context, new DeviceSession(null, null, null));
    // Verify
    assertThat(context.hasErrors()).isTrue();
    assertThat(messageCollector.getMessages()).contains("Blaze build failed. See Blaze Console for details.");
}
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) File(java.io.File) Test(org.junit.Test)

Aggregations

AndroidDeployInfo (com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.AndroidDeployInfo)6 BlazeAndroidDeployInfo (com.google.idea.blaze.android.run.deployinfo.BlazeAndroidDeployInfo)6 BlazeApkDeployInfoProtoHelper (com.google.idea.blaze.android.run.deployinfo.BlazeApkDeployInfoProtoHelper)6 DeviceSession (com.google.idea.blaze.android.run.runner.BlazeAndroidDeviceSelector.DeviceSession)6 FullApkBuildStep (com.google.idea.blaze.android.run.runner.FullApkBuildStep)6 BuildResultHelper (com.google.idea.blaze.base.command.buildresult.BuildResultHelper)6 Test (org.junit.Test)6 File (java.io.File)5 RemoteApkDownloader (com.google.idea.blaze.android.run.RemoteApkDownloader)2 GetDeployInfoException (com.google.idea.blaze.android.run.deployinfo.BlazeApkDeployInfoProtoHelper.GetDeployInfoException)1 ParsedBepOutput (com.google.idea.blaze.base.command.buildresult.ParsedBepOutput)1 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)1