Skip to content

Commit

Permalink
[build] enable all One .NET MSBuild tests
Browse files Browse the repository at this point in the history
This is WIP, but this will enable all tests except for the
`dotnet-ignore`, `AOT`, `mkbundle`, and `mono-symbolicate` categories.

I'll see what the failures look like before deciding the final
categories here.
  • Loading branch information
jonathanpeppers committed Jun 29, 2020
1 parent f8eb265 commit 7676bbf
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 74 deletions.
8 changes: 8 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,10 @@ stages:
parameters:
node_id: 3

- template: yaml-templates\run-msbuild-mac-tests.yaml
parameters:
node_id: 4

# Xamarin.Android (Test MSBuild - Windows)
- template: yaml-templates\run-msbuild-win-tests.yaml
parameters:
Expand All @@ -812,6 +816,10 @@ stages:
parameters:
node_id: 3

- template: yaml-templates\run-msbuild-win-tests.yaml
parameters:
node_id: 4

# Check - "Xamarin.Android (Test MSBuild With Emulator - macOS)"
- job: mac_msbuilddevice_tests
displayName: MSBuild With Emulator - macOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ jobs:
nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3"
testResultsFile: TestResult-MSBuildTests-macOS-NoNode-$(XA.Build.Configuration).xml

# Only run these tests on node 4
- ${{ if eq(parameters.node_id, 4) }}:
- template: run-nunit-tests.yaml
parameters:
testRunTitle: Xamarin.Android.Build.Tests - macOS - One .NET
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/Xamarin.Android.Build.Tests.dll
nunitConsoleExtraArgs: --where "cat == dotnet" --params dotnet=true
nunitConsoleExtraArgs: --where "cat != dotnet-ignore && cat != AOT && cat != mkbundle && cat != mono-symbolicate" --params dotnet=true
testResultsFile: TestResult-MSBuildTests-macOS-dotnet-$(XA.Build.Configuration).xml

- template: upload-results.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ jobs:
nunitConsoleExtraArgs: --workers=4 --where "cat != Node-1 && cat != Node-2 && cat != Node-3"
testResultsFile: TestResult-MSBuildTests-Windows-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml

# Only run these tests on node 4
- ${{ if eq(parameters.node_id, 4) }}:
- template: run-nunit-tests.yaml
parameters:
testRunTitle: Xamarin.Android.Build.Tests - Windows - One .NET
testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.dll
nunitConsoleExtraArgs: --workers=4 --where "cat == dotnet" --params dotnet=true
nunitConsoleExtraArgs: --workers=4 --where "cat != dotnet-ignore && cat != AOT && cat != mkbundle && cat != mono-symbolicate" --params dotnet=true
testResultsFile: TestResult-MSBuildTests-Windows-dotnet-$(XA.Build.Configuration).xml

- template: upload-results.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' ">SdkOnly</AndroidLinkMode>
<AndroidManagedSymbols Condition=" '$(AndroidManagedSymbols)' == '' ">true</AndroidManagedSymbols>
</PropertyGroup>
<PropertyGroup>
<PublishTrimmed Condition=" '$(AndroidLinkMode)' == 'SdkOnly' or '$(AndroidLinkMode)' == 'Full' ">true</PublishTrimmed>
</PropertyGroup>

<Import Project="Microsoft.Android.Sdk.BundledVersions.props" Condition=" Exists('Microsoft.Android.Sdk.BundledVersions.props') " />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<AndroidManifest Condition=" '$(AndroidManifest)' == '' And '$(AndroidApplication)' == 'true' ">Properties\AndroidManifest.xml</AndroidManifest>
<!-- We don't ever need a `static void Main` method, so switch to Library here-->
<OutputType Condition=" '$(OutputType)' == 'Exe' ">Library</OutputType>
<PublishTrimmed Condition=" '$(AndroidLinkMode)' == 'SdkOnly' or '$(AndroidLinkMode)' == 'Full' ">true</PublishTrimmed>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void BuildBasicApplication ([Values (true, false)] bool isRelease)
}

[Test]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("AOT")]
public void BuildBasicApplicationReleaseProfiledAot ()
{
var proj = new XamarinAndroidApplicationProject () {
Expand All @@ -51,7 +51,7 @@ public void BuildBasicApplicationReleaseProfiledAot ()
}
}

[Test]
[Test, Category ("AOT")]
public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile ()
{
var proj = new XamarinAndroidApplicationProject () {
Expand Down Expand Up @@ -904,7 +904,7 @@ public void CSharp8Features ([Values (true, false)] bool bindingProject)
}

[Test]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("mkbundle")]
public void BuildMkBundleApplicationRelease ()
{
var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true };
Expand All @@ -930,11 +930,11 @@ public void BuildMkBundleApplicationRelease ()
}

[Test]
[Category ("Minor")]
[Category ("Minor"), Category ("mkbundle")]
public void BuildMkBundleApplicationReleaseAllAbi ()
{
var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true };
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
using (var b = CreateApkBuilder ("temp/BuildMkBundleApplicationReleaseAllAbi", false)) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
foreach (var abi in new string [] { "armeabi-v7a", "x86" }) {
Expand All @@ -960,7 +960,7 @@ public void BuildMkBundleApplicationReleaseAllAbi ()

[Test]
[TestCaseSource (nameof (AotChecks))]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("AOT")]
public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM, bool expectedResult)
{
var path = Path.Combine ("temp", string.Format ("BuildAotApplication AndÜmläüts_{0}_{1}_{2}", supportedAbis, enableLLVM, expectedResult));
Expand All @@ -970,7 +970,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL
AotAssemblies = true,
};
proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1");
proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis);
proj.SetAndroidSupportedAbis (supportedAbis);
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
bool checkMinLlvmPath = enableLLVM && (supportedAbis == "armeabi-v7a" || supportedAbis == "x86");
if (checkMinLlvmPath) {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL

[Test]
[TestCaseSource (nameof (AotChecks))]
[Category ("Minor")]
[Category ("Minor"), Category ("mkbundle"), Category ("AOT")]
public void BuildAotApplicationAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM, bool expectedResult)
{
var path = Path.Combine ("temp", string.Format ("BuildAotApplicationAndBundle AndÜmläüts_{0}_{1}_{2}", supportedAbis, enableLLVM, expectedResult));
Expand All @@ -1039,7 +1039,7 @@ public void BuildAotApplicationAndBundleAndÜmläüts (string supportedAbis, boo
AotAssemblies = true,
};
proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1");
proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis);
proj.SetAndroidSupportedAbis (supportedAbis);
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
using (var b = CreateApkBuilder (path)) {
if (!b.CrossCompilerAvailable (supportedAbis))
Expand Down Expand Up @@ -1117,7 +1117,7 @@ public void BuildProguardEnabledProject ([Values (true, false)] bool isRelease,
var classes = new [] {
"Lmono/MonoRuntimeProvider;",
"Landroid/runtime/JavaProxyThrowable;",
"Landroid/support/v7/widget/Toolbar;"
Builder.UseDotNet ? "Landroidx/appcompat/widget/Toolbar;" : "Landroid/support/v7/widget/Toolbar;"
};
foreach (var className in classes) {
Assert.IsTrue (DexUtils.ContainsClassWithMethod (className, "<init>", "()V", dexFile, AndroidSdkPath), $"`{dexFile}` should include `{className}`!");
Expand Down Expand Up @@ -1176,15 +1176,15 @@ public void BuildMultiDexApplication ([Values ("dx", "d8")] string dexTool)
proj.UseLatestPlatformSdk = false;
proj.DexTool = dexTool;
proj.SetProperty ("AndroidEnableMultiDex", "True");
if (IsWindows) {
if (IsWindows && !Builder.UseDotNet) {
proj.SetProperty ("AppendTargetFrameworkToIntermediateOutputPath", "True");
}

using (var b = CreateApkBuilder (Path.Combine ("temp", TestName), false, false)) {
proj.TargetFrameworkVersion = b.LatestTargetFrameworkVersion ();

string intermediateDir;
if (IsWindows) {
if (IsWindows && !Builder.UseDotNet) {
intermediateDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, proj.TargetFrameworkAbbreviated);
} else {
intermediateDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
Expand All @@ -1195,7 +1195,8 @@ public void BuildMultiDexApplication ([Values ("dx", "d8")] string dexTool)
var multidexKeepPath = Path.Combine (Root, b.ProjectDirectory, intermediateDir, "multidex.keep");
Assert.IsTrue (File.Exists (multidexKeepPath), "multidex.keep exists");
Assert.IsTrue (File.ReadAllLines (multidexKeepPath).Length > 1, "multidex.keep must contain more than one line.");
Assert.IsTrue (b.LastBuildOutput.ContainsText (Path.Combine (proj.TargetFrameworkVersion, "mono.android.jar")), proj.TargetFrameworkVersion + "/mono.android.jar should be used.");
if (!Builder.UseDotNet)
Assert.IsTrue (b.LastBuildOutput.ContainsText (Path.Combine (proj.TargetFrameworkVersion, "mono.android.jar")), proj.TargetFrameworkVersion + "/mono.android.jar should be used.");
Assert.IsFalse (b.LastBuildOutput.ContainsText ("Duplicate zip entry"), "Should not get warning about [META-INF/MANIFEST.MF]");
}
}
Expand Down Expand Up @@ -1996,6 +1997,7 @@ public void CheckWhichRuntimeIsIncluded (string supportedAbi, bool debugSymbols,
}

[Test]
[Category ("AOT"), Category ("mono-symbolicate")]
[TestCaseSource (nameof (SequencePointChecks))]
public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive, bool aotAssemblies,
bool debugSymbols, string debugType, bool embedMdb, string expectedRuntime)
Expand All @@ -2004,8 +2006,8 @@ public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive
IsRelease = isRelease,
AotAssemblies = aotAssemblies
};
var abis = new string [] { "armeabi-v7a", "x86" };
proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis));
var abis = new [] { "armeabi-v7a", "x86" };
proj.SetAndroidSupportedAbis (abis);
proj.SetProperty (proj.ActiveConfigurationProperties, "MonoSymbolArchive", monoSymbolArchive);
proj.SetProperty (proj.ActiveConfigurationProperties, "DebugSymbols", debugSymbols);
proj.SetProperty (proj.ActiveConfigurationProperties, "DebugType", debugType);
Expand Down Expand Up @@ -2115,7 +2117,7 @@ public void BuildWithNativeLibraries ([Values (true, false)] bool isRelease)
}
};
proj.SetProperty ("TargetFrameworkVersion", "v7.1");
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
proj.MainActivity = proj.DefaultMainActivity.Replace ("int count = 1;", @"int count = 1;
Mono.Data.Sqlite.SqliteConnection connection = null;
Mono.Unix.UnixFileInfo fileInfo = null;");
Expand Down Expand Up @@ -2173,7 +2175,7 @@ public void BuildWithNativeLibraryUnknownAbi ()
},
}
};
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");

using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
builder.ThrowOnBuildFailure = false;
Expand Down Expand Up @@ -2562,7 +2564,7 @@ public void BuildReleaseApplication ()
}

[Test]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("AOT")]
public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enableMultiDex, [Values ("dx", "d8")] string dexTool, [Values ("", "proguard", "r8")] string linkTool)
{
var folderName = $"BuildReleaseApp AndÜmläüts({enableMultiDex}{dexTool}{linkTool})";
Expand Down Expand Up @@ -3212,6 +3214,7 @@ public void IfAndroidJarDoesNotExistThrowXA5207 ()
}

[Test]
[Category ("AOT"), Category ("mkbundle")]
[TestCase ("AotAssemblies", false)]
[TestCase ("AndroidEnableProfiledAot", false)]
[TestCase ("EnableLLVM", true)]
Expand Down Expand Up @@ -3383,7 +3386,7 @@ public void ValidateUseLatestAndroid ()

[Test]
[NonParallelizable]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("AOT")]
public void BuildAMassiveApp()
{
var testPath = Path.Combine("temp", "BuildAMassiveApp");
Expand Down Expand Up @@ -3740,13 +3743,14 @@ public void MicrosoftExtensionsHttp ()
}

[Test]
[Category ("dotnet-ignore")]
[TestCase ("armeabi;armeabi-v7a", TestName = "XA0115")]
[TestCase ("armeabi,armeabi-v7a", TestName = "XA0115Commas")]
public void XA0115 (string abis)
{
var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty (KnownProperties.AndroidSupportedAbis, abis);
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
using (var builder = CreateApkBuilder ()) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed with XA0115.");
StringAssertEx.Contains ($"error XA0115", builder.LastBuildOutput, "Error should be XA0115");
Expand Down Expand Up @@ -4105,6 +4109,7 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2)
}

[Test]
[Category ("dotnet-ignore")]
public void AbiDelimiters ([Values ("armeabi-v7a%3bx86", "armeabi-v7a,x86")] string abis)
{
var proj = new XamarinAndroidApplicationProject ();
Expand Down Expand Up @@ -4211,7 +4216,7 @@ public void PackageNamingPolicy ([Values ("LowercaseMD5", "LowercaseCrc64")] str
{
var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty ("AndroidPackageNamingPolicy", packageNamingPolicy);
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
var environment = b.Output.GetIntermediaryPath (Path.Combine ("__environment__.txt"));
Expand Down Expand Up @@ -4293,6 +4298,7 @@ public void XA4310 ([Values ("apk", "aab")] string packageFormat)
}

[Test]
[Category ("AOT")]
public void HybridAOT ()
{
var proj = new XamarinAndroidApplicationProject () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public void BuildApplicationWithMonoEnvironment ([Values ("", "Normal", "Offline
},
};
//LinkSkip one assembly that contains __AndroidLibraryProjects__.zip
string linkSkip = KnownPackages.SupportV7AppCompat_27_0_2_1.Id;
string linkSkip = "FormsViewGroup";
app.SetProperty ("AndroidLinkSkip", linkSkip);
app.SetProperty ("_AndroidSequencePointsMode", sequencePointsMode);
app.SetProperty (app.ReleaseProperties, KnownProperties.AndroidSupportedAbis, supportedAbis);
app.SetAndroidSupportedAbis (supportedAbis);
using (var libb = CreateDllBuilder (Path.Combine ("temp", TestName, lib.ProjectName)))
using (var appb = CreateApkBuilder (Path.Combine ("temp", TestName, app.ProjectName))) {
Assert.IsTrue (libb.Build (lib), "Library build should have succeeded.");
Expand Down Expand Up @@ -85,7 +85,7 @@ public void CheckMonoDebugIsAddedToEnvironment ([Values ("", "Normal", "Offline"
IsRelease = true,
};
proj.SetProperty ("_AndroidSequencePointsMode", sequencePointsMode);
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, supportedAbis);
proj.SetAndroidSupportedAbis (supportedAbis);
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
b.Verbosity = LoggerVerbosity.Diagnostic;
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Expand Down Expand Up @@ -118,7 +118,7 @@ public void CheckConcurrentGC ()
var expectedDefaultValue = "major=marksweep";
var expectedUpdatedValue = "major=marksweep-conc";
var supportedAbis = "armeabi-v7a;arm64-v8a";
proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis);
proj.SetAndroidSupportedAbis (supportedAbis);

using (var b = CreateDllBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Expand All @@ -139,6 +139,7 @@ public void CheckConcurrentGC ()
}

[Test]
[Category ("mono-symbolicate")]
public void CheckBuildIdIsUnique ([Values ("apk", "aab")] string packageFormat)
{
const string supportedAbis = "armeabi-v7a;x86";
Expand All @@ -151,8 +152,8 @@ public void CheckBuildIdIsUnique ([Values ("apk", "aab")] string packageFormat)
proj.SetProperty (proj.ReleaseProperties, "DebugSymbols", "true");
proj.SetProperty (proj.ReleaseProperties, "DebugType", "PdbOnly");
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, "true");
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, supportedAbis);
proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat);
proj.SetAndroidSupportedAbis (supportedAbis);
using (var b = CreateApkBuilder ()) {
b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic;
b.ThrowOnBuildFailure = false;
Expand Down Expand Up @@ -200,7 +201,7 @@ public void CheckHttpClientHandlerType ()
var expectedDefaultValue = "System.Net.Http.HttpClientHandler, System.Net.Http";
var expectedUpdatedValue = "Xamarin.Android.Net.AndroidClientHandler";
var supportedAbis = "armeabi-v7a;arm64-v8a";
proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis);
proj.SetAndroidSupportedAbis (supportedAbis);

using (var b = CreateDllBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Expand Down Expand Up @@ -229,14 +230,15 @@ public void CheckHttpClientHandlerType ()
};

[Test]
[Category ("dotnet-ignore")] // .NET 5+ does not use these native libraries
[TestCaseSource (nameof (TlsProviderTestCases))]
public void BuildWithTlsProvider (string androidTlsProvider, bool isRelease, bool expected)
{
var proj = new XamarinAndroidApplicationProject () {
IsRelease = isRelease,
};
var supportedAbis = new string [] { "armeabi-v7a", "arm64-v8a" };
proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", supportedAbis));
proj.SetAndroidSupportedAbis (supportedAbis);

using (var b = CreateApkBuilder (Path.Combine ("temp", $"BuildWithTlsProvider_{androidTlsProvider}_{isRelease}_{expected}"))) {
proj.SetProperty ("AndroidTlsProvider", androidTlsProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, Pro
#pragma warning restore 414

[Test]
[Category ("AOT")]
[TestCaseSource (nameof (AotChecks))]
public void BuildIncrementalAot (string supportedAbis, string androidAotMode, bool aotAssemblies, bool expectedResult)
{
Expand Down Expand Up @@ -1167,11 +1168,13 @@ public void AndroidXMigrationBug ()
public void ChangeSupportedAbis ()
{
var proj = new XamarinFormsAndroidApplicationProject ();
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a");
proj.SetAndroidSupportedAbis ("armeabi-v7a");
using (var b = CreateApkBuilder ()) {
b.Build (proj);

var parameters = new [] { $"{KnownProperties.AndroidSupportedAbis}=x86" };
var parameters = Builder.UseDotNet ?
new [] { $"{KnownProperties.RuntimeIdentifier}=android.21-x86" } :
new [] { $"{KnownProperties.AndroidSupportedAbis}=x86" };
b.Build (proj, parameters: parameters, doNotCleanupOnUpdate: true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Xamarin.Android.Build.Tests
{
[TestFixture]
[NonParallelizable] // On MacOS, parallel /restore causes issues
[Category ("Node-3")]
[Category ("Node-3"), Category ("dotnet-ignore")]
public class MSBuildSdkExtrasTests : BaseTest
{
[Test]
Expand Down
Loading

0 comments on commit 7676bbf

Please sign in to comment.