Skip to content

The task errors in apk tests are ignored #2732

Open
@radekdoulik

Description

@radekdoulik

When running the tests using make run-apk-tests, the invoked msbuild tool doesn't fail, when some of the tasks in RunApkTest.targets fails.

It looks like the issue here happens, when we use the MSBuild task to run the RunApkTests target, which depends on multiple other targets, which prepare and run the tests. When any of the tasks in the dependency targets fails, the MSBuild task in outer msbuild project doesn't fail and so the outer project ends as Successful build.

Following example demonstrates that:

test-outer.csproj

<Project DefaultTargets="FakeBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="FakeBuild">
    <MSBuild Projects="test.csproj" />
  </Target>
</Project>

test.csproj

<Project DefaultTargets="FakeBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="Fail">
    <Exec Command="exit 1" ContinueOnError="ErrorAndContinue" />
  </Target>
  <Target Name="FakeBuild" DependsOnTargets="Fail">
    <Message Text="Building after error..."/>
  </Target>
</Project>

Run the example:

msbuild test-outer.csproj
Microsoft (R) Build Engine version 16.0.40-preview+g105cb8a157 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2/13/2019 6:15:19 PM.
Project "/Users/rodo/git/xa/test-outer.csproj" on node 1 (default targets).
Project "/Users/rodo/git/xa/test-outer.csproj" (1) is building "/Users/rodo/git/xa/test.csproj" (2) on node 1 (default targets).
Fail:
  exit 1
/Users/rodo/git/xa/test.csproj(3,5): error MSB3073: The command "exit 1" exited with code 1.
  Build continuing because "ContinueOnError" on the task "Exec" is set to "ErrorAndContinue".
FakeBuild:
  Building after error...
Done Building Project "/Users/rodo/git/xa/test.csproj" (default targets) -- FAILED.
Done Building Project "/Users/rodo/git/xa/test-outer.csproj" (default targets).

Build succeeded.

"/Users/rodo/git/xa/test-outer.csproj" (default target) (1) ->
"/Users/rodo/git/xa/test.csproj" (default target) (2) ->
(Fail target) -> 
  /Users/rodo/git/xa/test.csproj(3,5): error MSB3073: The command "exit 1" exited with code 1.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.46

Note, that the Error is reported in the output, but the build succeeds and the exit code of msbuild is 0.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions