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`, `dotnet-todo`, `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 Jul 13, 2020
1 parent 1b5193c commit 639062f
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 72 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 @@ -824,6 +824,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 @@ -837,6 +841,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 != dotnet-todo && 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 != dotnet-todo && 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 @@ -17,6 +17,17 @@ namespace Xamarin.Android.Build.Tests
[Parallelizable (ParallelScope.Children)]
public class AndroidUpdateResourcesTest : BaseTest
{
string GetResourceDesignerPath (ProjectBuilder builder, XamarinAndroidProject project)
{
string path;
if (Builder.UseDotNet) {
path = Path.Combine (Root, builder.ProjectDirectory, project.IntermediateOutputPath);
} else {
path = Path.Combine (Root, builder.ProjectDirectory, "Resources");
}
return Path.Combine (path, "Resource.designer" + project.Language.DefaultDesignerExtension);
}

[Test]
public void CheckMultipleLibraryProjectReferenceAlias ([Values (true, false)] bool withGlobal)
{
Expand Down Expand Up @@ -47,7 +58,8 @@ public void CheckMultipleLibraryProjectReferenceAlias ([Values (true, false)] bo
using (var b = CreateApkBuilder (Path.Combine (path, proj.ProjectName), cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
b.ThrowOnBuildFailure = false;
Assert.IsTrue (b.Build (proj), "Project should have built.");
string[] text = File.ReadAllLines (Path.Combine (Root, path, proj.ProjectName, "Resources", "Resource.designer.cs"));
string resource_designer_cs = GetResourceDesignerPath (builder2, proj);
string[] text = File.ReadAllLines (resource_designer_cs);
Assert.IsTrue (text.Count (x => x.Contains ("Library1.Resource.String.library_name")) == 2, "library_name resource should be present exactly once for each library");
Assert.IsTrue (text.Count (x => x == "extern alias Lib1A;" || x == "extern alias Lib1B;") <= 1, "No more than one extern alias should be present for each library.");
}
Expand Down Expand Up @@ -586,7 +598,7 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL
};
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
var designerPath = Path.Combine (Root, b.ProjectDirectory, "Resources", "Resource.designer" + proj.Language.DefaultDesignerExtension);
var designerPath = GetResourceDesignerPath (b, proj);
var attr = File.GetAttributes (designerPath);
File.SetAttributes (designerPath, FileAttributes.ReadOnly);
Assert.IsTrue ((File.GetAttributes (designerPath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly,
Expand Down Expand Up @@ -818,7 +830,6 @@ public void CheckFilesAreRemoved () {
KnownPackages.AndroidSupportV4_27_0_2_1,
},
};
proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1");
using (var builder = CreateApkBuilder ("temp/CheckFilesAreRemoved", false, false)) {
builder.Verbosity = LoggerVerbosity.Diagnostic;
Assert.IsTrue (builder.Build (proj), "Build should have succeeded");
Expand Down Expand Up @@ -912,7 +923,8 @@ public string GetFoo () {
Assert.IsFalse (libBuilder.Output.IsTargetSkipped ("_CreateManagedLibraryResourceArchive"), "_CreateManagedLibraryResourceArchive should not be skipped.");
appBuilder.BuildLogFile = "build2.log";
Assert.IsTrue (appBuilder.Build (appProj, doNotCleanupOnUpdate: true, saveProject: false), "Application Build should have succeeded.");
string text = File.ReadAllText (Path.Combine (Root, path, appProj.ProjectName, "Resources", "Resource.designer.cs"));
string resource_designer_cs = GetResourceDesignerPath (appBuilder, appProj);
string text = File.ReadAllText (resource_designer_cs);
Assert.IsTrue (text.Contains ("theme_devicedefault_background2"), "Resource.designer.cs was not updated.");
Assert.IsFalse (appBuilder.Output.IsTargetSkipped ("_UpdateAndroidResgen"), "_UpdateAndroidResgen target should NOT be skipped.");
Assert.IsFalse (appBuilder.Output.IsTargetSkipped ("_CreateBaseApk"), "_CreateBaseApk target should NOT be skipped.");
Expand Down Expand Up @@ -1280,6 +1292,7 @@ public void CustomViewAddResourceId ([Values (false, true)] bool useAapt2)
// https://github.com/xamarin/xamarin-android/issues/2205
[Test]
[NonParallelizable]
[Category ("dotnet-ignore")] // <ProcessGoogleServicesJson/> task is built for net45
public void Issue2205 ([Values (false, true)] bool useAapt2)
{
var proj = new XamarinAndroidApplicationProject ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void CleanBasicBindingLibrary (string classParser)

[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void BuildAarBindigLibraryStandalone (string classParser)
{
var proj = new XamarinAndroidBindingProject () {
Expand All @@ -109,6 +110,7 @@ public void BuildAarBindigLibraryStandalone (string classParser)

[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser)
{
var proj = new XamarinAndroidBindingProject () {
Expand All @@ -135,7 +137,7 @@ public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser)
[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[NonParallelizable]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void BuildLibraryZipBindigLibraryWithAarOfJar (string classParser)
{
var proj = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -209,6 +211,7 @@ public void BindByteArrayInMethodParameter ()
}

[Test]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void MergeAndroidManifest ()
{
var binding = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -239,6 +242,7 @@ public void MergeAndroidManifest ()
}

[Test]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void AnnotationSupport ()
{
// https://trello.com/c/a36dDVS6/37-support-for-annotations-zip
Expand Down Expand Up @@ -278,6 +282,7 @@ public void BindingCustomJavaApplicationClass ()
}

[Test]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void BindngFilterUnsupportedNativeAbiLibraries ()
{
var binding = new XamarinAndroidBindingProject () {
Expand All @@ -298,6 +303,7 @@ public void BindngFilterUnsupportedNativeAbiLibraries ()
}

[Test]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void BindingCheckHiddenFiles ([Values (true, false)] bool useShortFileNames)
{
var binding = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -405,6 +411,7 @@ public void OnUpdate (Java.Lang.Object p0)
}

[Test]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void RemoveEventHandlerResolution ()
{
var binding = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -479,6 +486,7 @@ static Version GetJdkVersion ()

[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[Category ("dotnet-todo")] // TODO: @(LibraryProjectZip) support
public void DesignTimeBuild (string classParser)
{
var proj = new XamarinAndroidBindingProject {
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 @@ -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 @@ -1994,6 +1995,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 @@ -2002,8 +2004,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 @@ -2113,7 +2115,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 @@ -2171,7 +2173,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 @@ -2560,7 +2562,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 @@ -3186,6 +3188,7 @@ public void IfAndroidJarDoesNotExistThrowXA5207 ()
}

[Test]
[Category ("AOT"), Category ("mkbundle")]
[TestCase ("AotAssemblies", false)]
[TestCase ("AndroidEnableProfiledAot", false)]
[TestCase ("EnableLLVM", true)]
Expand Down Expand Up @@ -3357,7 +3360,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 @@ -3714,13 +3717,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 @@ -4081,6 +4085,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 @@ -4187,7 +4192,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 @@ -4269,6 +4274,7 @@ public void XA4310 ([Values ("apk", "aab")] string packageFormat)
}

[Test]
[Category ("AOT")]
public void HybridAOT ()
{
var proj = new XamarinAndroidApplicationProject () {
Expand Down
Loading

0 comments on commit 639062f

Please sign in to comment.