-
Notifications
You must be signed in to change notification settings - Fork 565
Enable more tests to run on all 3 runtimes, part 1 #10573
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
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
3cce48b to
3d97d97
Compare
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
Outdated
Show resolved
Hide resolved
|
|
||
| [Test] | ||
| public void CheckItemMetadata ([Values (true, false)] bool isRelease) | ||
| public void CheckItemMetadata ([Values (true, false)] bool isRelease, [Values] AndroidRuntime runtime) |
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 know if NUnit automatically finds all the enums for you, if you do: [Values] AndroidRuntime runtime
Let's see what the test run does, but I wonder if NUnit will siliently error and skip this test?
Or if it works fine, today I learned!
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 you decorate a bool or an enum parameter with [Values], it will enumerate all the possible values, yep :) Very handy
| IsRelease = true, | ||
| AotAssemblies = true, | ||
| IsRelease = isRelease, | ||
| AotAssemblies = aotAssemblies, |
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.
Maybe we should add a helper method for AotAssemblies, where you pass in the AndroidRuntime? And it returns true for Mono and false for the others.
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 was considering doing that, yeah, but then I decided that tests should be explicit as much as possible in what they do (even if it's repetitive/verbose), they should be treated as separate entities without hidden code that does something.
I made an exception in the IgnoreUnsupportedConfiguration helper method because what it does can change in the future and it would be a real shame to have to go through all the tests and change them individually.
Another exception to this, but justified I think, is the SetRuntime method when called for NativeAOT, that's just environment setup unrelated to any particular test as such, so I think it's fine.
| return false; | ||
| } | ||
|
|
||
| Assert.Ignore ($"NativeAOT: unsupported configuration (release == {release})"); |
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 believe the way NUnit works, Assert.Ignore() throws an exception that tells NUnit to skip.
So, I think you could make this method void and you don't need an if-return statement in each test.
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.
Yeah, Assert.Ignore() throws an exception, but I wanted to make the action explicit for human readers - thus the if-return pattern. It's verbose and repetitive, but makes it clear what's the intention and consequence. The actual action of ignoring via Assert.Ignore is hidden from the person reading a specific unit test. It is implied by the name, but without checking what IgnoreUnsupportedConfiguration actually does, they don't know the consequences.
Unit tests are a peculiar thing, and I think verbosity (and code repetition) are perfectly fine there, even desired.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
3adffe6 to
98cb409
Compare
|
/azp run |
…sts/BuildTest.cs Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
98cb409 to
6562ebf
Compare
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Pull Request Overview
This PR enables more tests to run across all three Android runtimes (MonoVM, CoreCLR, and NativeAOT) by adding runtime parameters to test methods and implementing runtime-specific configuration handling.
Key Changes
- Added helper methods in
ProjectExtensions.csto configure projects for specific runtimes, with special handling for NativeAOT - Introduced
IgnoreUnsupportedConfiguration()inBaseTest.csto skip tests for unsupported runtime/configuration combinations - Updated 40+ test methods in
BuildTest.csto accept anAndroidRuntimeparameter and appropriately handle each runtime
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
ProjectExtensions.cs |
Refactored SetRuntime() with new overload for XamarinAndroidApplicationProject and extracted helper methods for NativeAOT handling |
BaseTest.cs |
Added IgnoreUnsupportedConfiguration() to validate and skip unsupported runtime/build configurations (NativeAOT requires release, CoreCLR doesn't support AOT) |
BuildTest.cs |
Expanded test coverage by adding AndroidRuntime parameter to numerous tests, with appropriate runtime configuration and validation logic |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs
Show resolved
Hide resolved
…sts/BuildTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sts/BuildTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sts/BuildTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sts/BuildTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.