From daa1ea2f7f720b99b1be045fc1414de25c706364 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Wed, 8 Mar 2017 21:08:18 -0500 Subject: [PATCH] [tests] Report an error when .apk tests crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While reviewing [PR 445][0] I noticed that it said that *41* tests had been run, and 0 failed. Compare to e.g. [PR 474][1], which has *164* passing tests. Something isn't right here. Further investigation showed that for PR 445, execution on the emulator had crashed ("Segmentation fault"). The error was ignored. Ignoring errors was in fact By Design™; see commit 6358a643. So what we need is for the `RunUnitTestApks` target to *not* report errors, while still reporting errors. Solve this conundrum by updating the `` task so that when the `nunit2-results-path` value can't be found, it reports a *successful* run, and sets the `RunInstrumentationTests.FailedToRun` property to the name of the component that failed. This allows the `ReleaseAndroidTarget` target to check for any failures, and report an `` after shutting down the emulator instance. This should allow the build to "fail" when `nunit2-results-path` can't be found -- a sign that the `.apk` unit tests didn't finish executing -- while also allowing the emulator to be shut down. Aside: `xbuild` doesn't support `ContinueOnError="ErrorAndContinue"`, nor does it set `` properties whenever a task fails. Consequently, the `` task *must* return true when `nunit2-results-path` isn't found, because there's no other way to convince `xbuild` to collect the `` values. [0]: https://github.com/xamarin/xamarin-android/pull/445 [1]: https://github.com/xamarin/xamarin-android/pull/474 --- build-tools/scripts/UnitTestApks.targets | 7 +++++-- .../RunInstrumentationTests.cs | 16 +++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/build-tools/scripts/UnitTestApks.targets b/build-tools/scripts/UnitTestApks.targets index 9bb4d6590f3..fdeaef1cf73 100644 --- a/build-tools/scripts/UnitTestApks.targets +++ b/build-tools/scripts/UnitTestApks.targets @@ -63,6 +63,10 @@ ToolExe="$(AdbToolExe)" ToolPath="$(AdbToolPath)" /> +