Skip to content

Conversation

@grendello
Copy link
Contributor

@grendello grendello commented Nov 20, 2025

NOTE: should be merged after #10585

Summary

This pull request enhances the test coverage and flexibility of the Xamarin.Android build tests by parameterizing tests to run across different Android runtimes and refactoring the way build properties are handled for NativeAOT scenarios. The changes ensure that tests are more robust and adaptable to future runtime changes, and they improve warning management—especially for CI environments.

Test Parameterization and Runtime Handling

  • Refactored all test methods in AssetPackTests.cs and CodeBehindTests.cs to use the [Values] attribute for both isRelease and AndroidRuntime runtime parameters, enabling comprehensive testing across all runtime configurations.
  • Added logic to skip unsupported runtime/configuration combinations using IgnoreUnsupportedConfiguration, preventing test failures on invalid configurations.

Build Properties and Warning Management

  • Refactored GetBuildProperties to dynamically construct the NoWarn property, including additional IL and XA warnings when running NativeAOT tests on CI, improving test reliability and output clarity.
  • Updated test logic to conditionally assert zero warnings for non-NativeAOT runs, accommodating known issues with NativeAOT builds.

Test Infrastructure Improvements

  • Enhanced the TestProjectInfo class to track the selected runtime and test root directory, supporting better test isolation and reporting.
  • Updated method signatures and invocations to consistently pass the runtime parameter through all test helpers and runners.

These changes collectively make the test suite more maintainable and future-proof, especially as new runtimes or build scenarios are introduced.

@grendello grendello changed the title Enable more tests to run on all 3 runtimes, part 5 Enable more tests to run on all 3 runtimes, part 6 Nov 20, 2025
@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch from 71c0fc0 to 4d78971 Compare November 21, 2025 11:19
@grendello grendello marked this pull request as ready for review November 21, 2025 15:52
@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch 2 times, most recently from 81a53cd to 79bbe97 Compare November 26, 2025 08:15
@grendello
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@grendello
Copy link
Contributor Author

/azp run

@grendello
Copy link
Contributor Author

Please CI deities, make it not time out this time?

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jonathanpeppers
Copy link
Member

I think SuccessfulBuildFew(NativeAOT) fails because it has warnings (AOT warnings) and then $(TreatWarningsAsErrors)=true in this test.

@grendello
Copy link
Contributor Author

I think SuccessfulBuildFew(NativeAOT) fails because it has warnings (AOT warnings) and then $(TreatWarningsAsErrors)=true in this test.

The odd thing is that this test doesn't fail locally:

[TESTLOG] Test SuccessfulBuildFewNativeAOT Starting
bin/Debug/dotnet/dotnet build bin/TestDebug/temp/CodeBehind/SuccessfulBuildFewNativeAOT/Debug/project/CodeBehindBuildTests.NET.csproj /t:SignAndroidPackage /noconsolelogger "/flp1:LogFile=bin/TestDebug/temp/CodeBehind/SuccessfulBuildFewNativeAOT/Debug/project/CodeBehindBuildTests.NET.SuccessfulBuildFewNativeAOT.log;Encoding=UTF-8;Verbosity=detailed" -nodeReuse:false @"bin/TestDebug/temp/CodeBehind/SuccessfulBuildFewNativeAOT/Debug/project/project.rsp"
Found Time Elapsed 00:00:31.0800000
[TESTLOG] Test SuccessfulBuildFewNativeAOT Complete
[TESTLOG] Test SuccessfulBuildFewNativeAOT Outcome=Passed

@grendello
Copy link
Contributor Author

And this is the reason why, it's Directory.Build.props from CI:

  <PropertyGroup>
    <!-- 
      Use $(TreatWarningsAsErrors) for CI builds. We have grandfathered some projects that have existing warnings,
      but we would like to go ahead and prevent any other projects from getting new warnings.
      
      This can be opted into locally with $(_AndroidTreatWarningsAsErrors) = true.
    -->
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'jnienv-gen.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Mono.Android.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Mono.Android.NET-Tests.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'MSBuildDeviceIntegration.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'NativeAOT.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'TestRunner.Core.NET.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Xamarin.Android.Build.Tests.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Xamarin.Android.JcwGen-Tests.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Xamarin.Android.NUnitLite.NET.csproj' ">true</_AllowProjectWarnings>
    <_AllowProjectWarnings Condition=" '$(MSBuildProjectFile)' == 'Xamarin.ProjectTools.csproj' ">true</_AllowProjectWarnings>
    <TreatWarningsAsErrors Condition=" ('$(RunningOnCI)' == 'true' OR '$(_AndroidTreatWarningsAsErrors)' == 'true') AND '$(_AllowProjectWarnings)' != 'true' ">true</TreatWarningsAsErrors>
  </PropertyGroup>

@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch 3 times, most recently from 0f1fb8a to 8ec7d61 Compare December 4, 2025 10:07
@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch 3 times, most recently from 024cc4e to 74d6990 Compare December 9, 2025 19:43
@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch from 74d6990 to 4e8003c Compare December 12, 2025 08:38
@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch 2 times, most recently from 5768795 to 058b806 Compare January 12, 2026 09:39
@grendello grendello force-pushed the dev/grendel/test-runtimes-6 branch from 058b806 to 2562ea9 Compare January 14, 2026 09:07
@jonathanpeppers jonathanpeppers merged commit bb2c376 into main Jan 16, 2026
1 of 2 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/grendel/test-runtimes-6 branch January 16, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants