-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[One .NET] Add Microsoft.Android-Tests unit tests #5250
Conversation
73bb0da
to
8a3bc77
Compare
71dd3c6
to
8b367fd
Compare
src/Mono.Android/Test/Java.Interop-Tests/Java.Interop-Tests.NET.csproj
Outdated
Show resolved
Hide resolved
build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs
Outdated
Show resolved
Hide resolved
@@ -453,7 +454,9 @@ public ContainsExportedMethods () | |||
Constructed = true; | |||
} | |||
|
|||
#if !NET // https://github.com/xamarin/xamarin-android/issues/5265 | |||
[Export] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be enough to disable the CreateTypeWithExportedMethods
test on dotnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nm. The build error is happening even when Mono.Android.Export
is referenced. I will look at how to fix #5265
tests/Runtime-Microsoft.Android.Sdk/Microsoft.Android-Tests.projitems
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,148 @@ | |||
<Project Sdk="Microsoft.NET.Sdk" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file also be added to Xamarin.Android-Tests.sln
?
<Import Project="Microsoft.Android-Tests.projitems" /> | ||
<Import Project="..\..\build-tools\scripts\TestApks.targets" /> | ||
|
||
<Target Name="GenerateNuGetConfig" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this file is added to Xamarin.Android-Tests.sln
, could you please test the following?
- Within Visual Studio for Mac,
- Load
Xamarin.Android-Tests.sln
. - Add a new project to the
.sln
.
What happens?
Normally, what would happen. is that every .csproj
in the .sln
is "re-formatted", screwing up whitespace, and requiring a git checkout -f HEAD …
to clean things up.
I don't know if this is still the case for .NET 5+ projects/SDK short-form projects. This is the case for "normal" projects.
It would likely be safer to move these <Target/>
s into Directory.Build.targets
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add this to Xamarin.Android-Tests.sln
at the moment, as it will break our macOS build job. These new project files will only compile against a specific version of .NET 5 that also has our workload installed into it. Additionally, I think there is still IDE work underway that will be needed to be able to load and use a project with a target framework of net5.0-android
. I will move the targets over, but I don't think we should include any net5.0-android
projects in our legacy solutions, or if we do want to do so eventually we should at least wait until there is a .NET 6 public preview available that supports it.
Context: dotnet#5250 PR dotnet#5250 will be adding another another Mono.Android-Tests project file, and it feels like a good time to move all relevant Mono.Android test source into a single location and reduce duplication where possible. The `src/Mono.Android/Test/` folder has been moved into the top level `tests` directory. The two existing `tests/Runtime-*` folders have been moved under the new `tests/Mono.Android-Tests` folder. Some duplication that existed in the .targets and .projitems files that belonged to these test projects has been cleaned up. The obsolete `TestInstrumentation` class has been deleted in favor of the newer `NUnitInstrumentation` class. The `Build.GetSerial ()` API is restricted on API 29+, so a check has been added to prevent the following exception: AndroidRuntime: FATAL EXCEPTION: Instr: xamarin.android.runtimetests.NUnitInstrumentation AndroidRuntime: Process: Mono.Android_Tests, PID: 3489 AndroidRuntime: java.lang.SecurityException: getSerial: The user 10106 does not meet the requirements to access device identifiers. AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2071) AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2039) AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1987) AndroidRuntime: at android.os.IDeviceIdentifiersPolicyService$Stub$Proxy.getSerialForPackage(IDeviceIdentifiersPolicyService.java:159) AndroidRuntime: at android.os.Build.getSerial(Build.java:162)
Context: dotnet#5250 PR dotnet#5250 will be adding another another Mono.Android-Tests project file, and it feels like a good time to move all relevant Mono.Android test source into a single location and reduce duplication where possible. The `src/Mono.Android/Test/` folder has been moved into the top level `tests` directory. The two existing `tests/Runtime-*` folders have been moved under the new `tests/Mono.Android-Tests` folder. Some duplication that existed in the .targets and .projitems files that belonged to these test projects has been cleaned up. The obsolete `TestInstrumentation` class has been deleted in favor of the newer `NUnitInstrumentation` class. The `Build.GetSerial ()` API is restricted on API 29+, so a check has been added to prevent the following exception: AndroidRuntime: FATAL EXCEPTION: Instr: xamarin.android.runtimetests.NUnitInstrumentation AndroidRuntime: Process: Mono.Android_Tests, PID: 3489 AndroidRuntime: java.lang.SecurityException: getSerial: The user 10106 does not meet the requirements to access device identifiers. AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2071) AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2039) AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1987) AndroidRuntime: at android.os.IDeviceIdentifiersPolicyService$Stub$Proxy.getSerialForPackage(IDeviceIdentifiersPolicyService.java:159) AndroidRuntime: at android.os.Build.getSerial(Build.java:162)
Context: #5250 PR #5250 will be adding another another Mono.Android-Tests project file, and it feels like a good time to move all relevant Mono.Android test source into a single location and reduce duplication. Move the `src/Mono.Android/Test/` folder to the `tests/Mono.Android-Tests` directory. The two existing `tests/Runtime-*` folders have been moved under the new `tests/Mono.Android-Tests` folder. Some duplication that existed in the `.targets` and `.projitems` files that belonged to these test projects has been cleaned up. The obsolete `TestInstrumentation` class has been deleted in favor of the newer `NUnitInstrumentation` class. The `Build.GetSerial ()` API is restricted on API 29+, so a check has been added to `TestInstrumentation.LogDeviceInfo()` to prevent the following exception: AndroidRuntime: FATAL EXCEPTION: Instr: xamarin.android.runtimetests.NUnitInstrumentation AndroidRuntime: Process: Mono.Android_Tests, PID: 3489 AndroidRuntime: java.lang.SecurityException: getSerial: The user 10106 does not meet the requirements to access device identifiers. AndroidRuntime: at android.os.Parcel.createException(Parcel.java:2071) AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2039) AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1987) AndroidRuntime: at android.os.IDeviceIdentifiersPolicyService$Stub$Proxy.getSerialForPackage(IDeviceIdentifiersPolicyService.java:159) AndroidRuntime: at android.os.Build.getSerial(Build.java:162)
0a57943
to
d8bde8a
Compare
A new version of Mono.Android-Tests has been added to run against the .NET 6 SDK: * `tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj` To support this, new .NET .csproj files have been added alongside all of the existing legacy Xamarin.Android unit test library projects. These projects target `net5.0-android` and build against our .NET 6 SDK: * `src/Mono.Android/Test/Java.Interop-Tests/Java.Interop-Tests.NET.csproj` * `src/Mono.Android/Test/Mono.Android-Test.Library/Mono.Android-Test.Library.NET.csproj` * `src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.NET.csproj` * `tests/TestRunner.Core/TestRunner.Core.NET.csproj` * `tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj` The `_CreateAar` target was being skipped for the new Java.Interop-Tests.NET project, as it had no inputs. As a result, the `Mono.Android-Test-classes.jar` file required by these tests was not being included in the application project. To fix this, I've added `@(AndroidJavaLibrary)` to `@(_CreateAarInputs)` so that these items will also be considered as inputs for this target/task.
d8bde8a
to
3544199
Compare
A new version of Mono.Android-Tests has been added to run against the
.NET 6 SDK:
tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj
To support this, new .NET .csproj files have been added alongside all of
the existing legacy Xamarin.Android unit test library projects. These
projects target
net5.0-android
and build against our .NET 6 SDK:src/Mono.Android/Test/Java.Interop-Tests/Java.Interop-Tests.NET.csproj
src/Mono.Android/Test/Mono.Android-Test.Library/Mono.Android-Test.Library.NET.csproj
src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.NET.csproj
tests/TestRunner.Core/TestRunner.Core.NET.csproj
tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj
The
_CreateAar
target was being skipped for the new Java.Interop-Tests.NETproject, as it had no inputs. As a result, the
Mono.Android-Test-classes.jar
file required by these tests was not being included in the application project.
To fix this, I've added
@(AndroidJavaLibrary)
to@(_CreateAarInputs)
so thatthese items will also be considered as inputs for this target/task.
All tests which have been ignored are tied back to one of the following issues: