Skip to content

[Mono.Android-Tests] Fix #1191, add new instrumentation class for new NUnit runner - #1413

Merged
jonpryor merged 4 commits into
dotnet:masterfrom
pjcollins:fix-1191
Mar 14, 2018
Merged

jonpryor merged 4 commits into
dotnet:masterfrom
pjcollins:fix-1191

Conversation

@pjcollins

@pjcollins pjcollins commented Mar 13, 2018 •

Copy link
Copy Markdown
Member
  • Fixes Encountering test failures in [EnsureAndroidManifestIsUpdated] on a Pixel 2 (8.1.0) #1191. The Mcc and Mnc values are now always present in ActivityInfo.ConfigChanges in Android 8.0+. The proposed fix is to ensure that ConfigChanges contains the KeyboardHidden flag , rather than requiring an exact match.
  • Adds new instrumentation for new NUnit runner.
  • Fixes possible NRE in new NUnit instrumentation/runner if test inclusion/exclusion data isn't provided.

Using the new NUnit runner is desirable as it is reliably producing test result xml files on device which can be pulled and published with ease. The previous runner had issues with certain devices when it came to providing the correct "on device" path to the test result xml. I've only marked the old instrumentation as obsolete (rather than deleting it) as I am not entirely familiar with how it is used in jenkins/wrench, and figured it could be cleaned up at a later date if those tools also want to migrate to use the new instrumentation/runner.

See #1191 for more
info. It seems that the `Mcc` and `Mnc` values are always present in
ActivityInfo.ConfigChanges in Android 8.0+. We'll now only check to make
sure `KeyboardHidden` has been set, rather than requiring an exact
match.
This fixes an NRE which will occur if the user does not set either
IncludedCateroies, ExcludedCategories, or ExcludedTestNames when
inheriting from NUnitTestInstrumentation. We should provide
an empty filter by default if there is no explicit inclusion/exclusion data specified
@pjcollins
pjcollins requested review from grendello and jonpryor March 13, 2018 20:05

namespace Xamarin.Android.RuntimeTests {

[Obsolete("Please use Xamarin.Android.RuntimeTests.NUnitTestInstrumentation")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks weird here. Is it a tabs-vs-spaces issue? Or is GitHub being weird?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the whitespace amount is off format here, I can fix it.

@jonpryor

Copy link
Copy Markdown
Contributor

This is odd; macOS+xbuild is failing because of emulator launching:

Error executing task CreateAndroidEmulator: System.IO.IOException: Write fault on path /Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/tests/[Unknown]
  at System.IO.FileStream.WriteInternal (System.Byte[] src, System.Int32 offset, System.Int32 count) [0x000be] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/b
System.IO/FileStream.cs:658 
  at System.IO.FileStream.Write (System.Byte[] array, System.Int32 offset, System.Int32 count) [0x00090] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/
.IO/FileStream.cs:614 
  at System.IO.StreamWriter.Flush (System.Boolean flushStream, System.Boolean flushEncoder) [0x0007e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mon
mscorlib/system/io/streamwriter.cs:318 
  at System.IO.StreamWriter.Write (System.Char[] buffer) [0x00079] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/msc
392 
  at System.IO.TextWriter.WriteLine () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/io/te

  at Xamarin.Android.Tools.BootstrapTasks.CreateAndroidEmulator.Exec (System.String android, System.String arguments, System.Diagnostics.DataReceivedEventHandler stderr) [0x00165] in /Users/builder/
d-pr-builder/xamarin-android/src/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CreateAndroidEmulator.cs:109 
  at Xamarin.Android.Tools.BootstrapTasks.CreateAndroidEmulator.Run (System.String android) [0x00028] in /Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/src/Xamarin.Andro
Android.Tools.BootstrapTasks/CreateAndroidEmulator.cs:70 
  at Xamarin.Android.Tools.BootstrapTasks.CreateAndroidEmulator.Execute () [0x001a9] in /Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/src/Xamarin.Android.Tools.Bootstra
tstrapTasks/CreateAndroidEmulator.cs:42 
  at Microsoft.Build.BuildEngine.TaskEngine.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/Microsoft.Build.Engin
e/Microsoft.Build.BuildEngine/TaskEngine.cs:134 

Write fault on path /Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/tests/[Unknown] is rather odd.

I'm restarting the build.

@jonpryor
jonpryor merged commit e201b54 into dotnet:master Mar 14, 2018
pjcollins added a commit that referenced this pull request Mar 14, 2018
Fixes: #1191

Fix the `ApplicationTest.EnsureAndroidManifestIsUpdated()` test when
running on a Google Pixel 2 w/ Android 8.1.0, as
`ActivityInfo.ConfigChanges` always contains the `ConfigChanges.Mcc`
and `ConfigChanges.Mnc` values on Android 8.0+. Explicitly check that
the `ConfigChanges.KeyboardHidden` flag is set, rather than the
entire value.

Update `src/Mono.Android/Test` to use the new `NUnitTestRunner`
in addition to `Xamarin.Android.NUnitLite`, as the `NUnitTestRunner`
reliably produces test result xml files on device which can be pulled
and published with ease.

Provide a default `TestFilter` value in `NUnitTestRunner`, to avoid a
`NullReferenceException` when `$(IncludedCategories)`,
`$(ExcludedCategories)`, or `$(ExcludedTestNames)` is not set.
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encountering test failures in [EnsureAndroidManifestIsUpdated] on a Pixel 2 (8.1.0)

3 participants