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
`DotNetIgnore`, `AOT`, `FSharp`, `LibraryProjectZip`, `MkBundle`,
`MonoSymbolicate`, and `PackagesConfig` categories.

* `AOT` - need Mono AOT support in .NET 5.
* `FSharp` - [Xamarin.Android.FSharp.ResourceProvider][0] support
  needed on .NET 5.
* `LibraryProjectZip` - will need future support in Xamarin.Android.
* `MkBundle` - may not ever come to .NET 5.
* `MonoSymbolicate` - need symbolication support in .NET 5.
* `PackagesConfig` - n/a for .NET 5.

I'll see what the failures look like before deciding the final
categories here.

[0]: https://github.com/xamarin/Xamarin.Android.FSharp.ResourceProvider
  • Loading branch information
jonathanpeppers committed Jul 23, 2020
1 parent 40a1ea3 commit 469a92d
Show file tree
Hide file tree
Showing 21 changed files with 303 additions and 183 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 @@ -827,6 +827,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 @@ -840,6 +844,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 != DotNetIgnore && cat != AOT && cat != FSharp && cat != LibraryProjectZip && cat != MkBundle && cat != MonoSymbolicate && cat != PackagesConfig" --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 != DotNetIgnore && cat != AOT && cat != FSharp && cat != LibraryProjectZip && cat != MkBundle && cat != MonoSymbolicate && cat != PackagesConfig" --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 @@ -79,6 +79,8 @@ public class ResolveAndroidTooling : AndroidTask

public override bool RunTask ()
{
AndroidApiLevel = GetMaxStableApiLevel ().ToString ();

string toolsZipAlignPath = Path.Combine (AndroidSdkPath, "tools", ZipAlign);
bool findZipAlign = (string.IsNullOrEmpty (ZipAlignPath) || !Directory.Exists (ZipAlignPath)) && !File.Exists (toolsZipAlignPath);

Expand Down Expand Up @@ -190,11 +192,7 @@ public override bool RunTask ()
return !Log.HasLoggedErrors;
}

protected virtual bool Validate ()
{
AndroidApiLevel = GetMaxStableApiLevel ().ToString ();
return true;
}
protected virtual bool Validate () => true;

protected virtual void LogOutputs ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ 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]
[Category ("dotnet")]
public void CheckMultipleLibraryProjectReferenceAlias ([Values (true, false)] bool withGlobal)
Expand Down Expand Up @@ -183,9 +172,11 @@ public void CheckEmbeddedSupportLibraryResources ()
KnownPackages.AndroidSupportV4_27_0_2_1,
KnownPackages.SupportV7AppCompat_27_0_2_1,
},
TargetFrameworkVersion = "v7.1",
};
using (var b = CreateApkBuilder ("temp/CheckEmbeddedSupportLibraryResources")) {
if (Builder.UseDotNet) {
proj.AddDotNetCompatPackages ();
}
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "First build should have succeeded.");
var Rdrawable = b.Output.GetIntermediaryPath (Path.Combine ("android", "bin", "classes", "android", "support", "v7", "appcompat", "R$drawable.class"));
Assert.IsTrue (File.Exists (Rdrawable), $"{Rdrawable} should exist");
Expand Down Expand Up @@ -292,6 +283,7 @@ public void RepetiviteBuildUpdateSingleResource ([Values (false, true)] bool use

[Test]
[NonParallelizable]
[Category ("DotNetIgnore")] // <ProcessGoogleServicesJson/> task is built for net45
public void Check9PatchFilesAreProcessed ()
{
var projectPath = Path.Combine ("temp", "Check9PatchFilesAreProcessed");
Expand Down Expand Up @@ -561,6 +553,9 @@ public void CheckResourceDesignerIsCreated (bool isRelease, ProjectLanguage lang
if (IsWindows && isFSharp) {
Assert.Ignore ("Skipping this F# test on Windows.");
}
if (Builder.UseDotNet && isFSharp) {
Assert.Ignore ("Skipping this F# test under 'dotnet'.");
}

var proj = new XamarinAndroidApplicationProject () {
Language = language,
Expand Down Expand Up @@ -589,17 +584,21 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL
{
//Due to the MSBuild project automatically sorting <ItemGroup />, we can't possibly get the F# projects to build here on Windows
// This API is sorting them: https://github.com/xamarin/xamarin-android/blob/c588bfe07aab224c97996a264579f4d4f18a151c/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetXamarinProject.cs#L117
if (IsWindows && language == XamarinAndroidProjectLanguage.FSharp) {
bool isFSharp = language == XamarinAndroidProjectLanguage.FSharp;
if (IsWindows && isFSharp) {
Assert.Ignore ("Skipping this F# test on Windows.");
}
if (Builder.UseDotNet && isFSharp) {
Assert.Ignore ("Skipping this F# test under 'dotnet'.");
}

var proj = new XamarinAndroidApplicationProject () {
Language = language,
IsRelease = isRelease,
};
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 @@ -629,13 +628,9 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL
}

[Test]
[TestCaseSource(nameof (ReleaseLanguage))]
public void CheckOldResourceDesignerIsNotUsed (bool isRelease, ProjectLanguage language)
public void CheckOldResourceDesignerIsNotUsed ([Values (true, false)] bool isRelease)
{
if (language == XamarinAndroidProjectLanguage.FSharp)
Assert.Ignore ("Skipping CheckOldResourceDesignerIsNotUsed for FSharp until Xamarin.Android.FSharp.ResourceProvider supports it.");
var proj = new XamarinAndroidApplicationProject () {
Language = language,
IsRelease = isRelease,
};
proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True");
Expand All @@ -660,13 +655,9 @@ public void CheckOldResourceDesignerIsNotUsed (bool isRelease, ProjectLanguage l

// ref https://bugzilla.xamarin.com/show_bug.cgi?id=30089
[Test]
[TestCaseSource(nameof (ReleaseLanguage))]
public void CheckOldResourceDesignerWithWrongCasingIsRemoved (bool isRelease, ProjectLanguage language)
public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values (true, false)] bool isRelease)
{
if (language == XamarinAndroidProjectLanguage.FSharp)
Assert.Ignore ("Skipping CheckOldResourceDesignerIsNotUsed for FSharp until Xamarin.Android.FSharp.ResourceProvider supports it.");
var proj = new XamarinAndroidApplicationProject () {
Language = language,
IsRelease = isRelease,
};
proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True");
Expand Down Expand Up @@ -1100,6 +1091,7 @@ public void BuildAppWithManagedResourceParserAndLibraries ()
}

[Test]
[Category ("DotNetIgnore")] // n/a in .NET 5, not possible to use $(TFV) of v8.0
public void CheckMaxResWarningIsEmittedAsAWarning([Values (false, true)] bool useAapt2)
{
var path = Path.Combine ("temp", TestName);
Expand Down Expand Up @@ -1299,6 +1291,7 @@ public void CustomViewAddResourceId ([Values (false, true)] bool useAapt2)
// https://github.com/xamarin/xamarin-android/issues/2205
[Test]
[NonParallelizable]
[Category ("DotNetIgnore")] // <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 @@ -25,14 +25,17 @@ public class BindingBuildTest : BaseTest {
public void BuildBasicBindingLibrary (string classParser)
{
var targets = new List<string> {
"_ExtractJavaDocJars",
"_ExportJarToXml",
"GenerateBindings",
"_CreateBindingResourceArchive",
"BuildDocumentation",
"_ResolveLibraryProjectImports",
"CoreCompile",
};
if (!Builder.UseDotNet) {
//TODO: .NET 5+ cannot support javadoc yet, due to missing mdoc
targets.Add ("_ExtractJavaDocJars");
targets.Add ("BuildDocumentation");
}

var proj = new XamarinAndroidBindingProject () {
IsRelease = true,
Expand Down Expand Up @@ -82,7 +85,9 @@ public void CleanBasicBindingLibrary (string classParser)
};
var files = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories)
.Where (x => !ignoreFiles.Any (i => !Path.GetFileName (x).Contains (i)));
Assert.AreEqual (0, Directory.GetDirectories (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories).Length,
var directories = Directory.GetDirectories (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories)
.Where (x => Path.GetFileName (x) != "designtime");
Assert.AreEqual (0, directories.Count (),
"All directories in {0} should have been removed", proj.IntermediateOutputPath);
Assert.AreEqual (0, files.Count (), "{0} should be empty. Found {1}",
proj.IntermediateOutputPath, string.Join (Environment.NewLine, files));
Expand All @@ -91,6 +96,7 @@ public void CleanBasicBindingLibrary (string classParser)

[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[Category ("LibraryProjectZip")]
public void BuildAarBindigLibraryStandalone (string classParser)
{
var proj = new XamarinAndroidBindingProject () {
Expand All @@ -109,6 +115,7 @@ public void BuildAarBindigLibraryStandalone (string classParser)

[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[Category ("LibraryProjectZip")]
public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser)
{
var proj = new XamarinAndroidBindingProject () {
Expand All @@ -135,7 +142,7 @@ public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser)
[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[NonParallelizable]
[Category ("SmokeTests")]
[Category ("SmokeTests"), Category ("LibraryProjectZip")]
public void BuildLibraryZipBindigLibraryWithAarOfJar (string classParser)
{
var proj = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -209,6 +216,7 @@ public void BindByteArrayInMethodParameter ()
}

[Test]
[Category ("LibraryProjectZip")]
public void MergeAndroidManifest ()
{
var binding = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -239,6 +247,7 @@ public void MergeAndroidManifest ()
}

[Test]
[Category ("LibraryProjectZip")]
public void AnnotationSupport ()
{
// https://trello.com/c/a36dDVS6/37-support-for-annotations-zip
Expand All @@ -261,6 +270,7 @@ public void BindingCustomJavaApplicationClass ()
{
var binding = new XamarinAndroidBindingProject () {
IsRelease = true,
ProjectName = "Binding",
};
binding.AndroidClassParser = "class-parse";

Expand All @@ -269,7 +279,7 @@ public void BindingCustomJavaApplicationClass ()
binding.Jars.Add (new AndroidItem.EmbeddedJar (() => multidexJar));
bindingBuilder.Build (binding);
var proj = new XamarinAndroidApplicationProject ();
proj.OtherBuildItems.Add (new BuildItem ("ProjectReference", "..\\MultiDexBinding\\UnnamedProject.csproj"));
proj.OtherBuildItems.Add (new BuildItem ("ProjectReference", $"..\\MultiDexBinding\\{binding.ProjectName}.csproj"));
using (var b = CreateApkBuilder ("temp/BindingCustomJavaApplicationClass/App")) {
b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic;
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Expand All @@ -278,6 +288,7 @@ public void BindingCustomJavaApplicationClass ()
}

[Test]
[Category ("LibraryProjectZip")]
public void BindngFilterUnsupportedNativeAbiLibraries ()
{
var binding = new XamarinAndroidBindingProject () {
Expand All @@ -298,6 +309,7 @@ public void BindngFilterUnsupportedNativeAbiLibraries ()
}

[Test]
[Category ("LibraryProjectZip")]
public void BindingCheckHiddenFiles ()
{
var binding = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -395,6 +407,7 @@ public void OnUpdate (Java.Lang.Object p0)
}

[Test]
[Category ("LibraryProjectZip")]
public void RemoveEventHandlerResolution ()
{
var binding = new XamarinAndroidBindingProject () {
Expand Down Expand Up @@ -469,6 +482,7 @@ static Version GetJdkVersion ()

[Test]
[TestCaseSource (nameof (ClassParseOptions))]
[Category ("LibraryProjectZip")]
public void DesignTimeBuild (string classParser)
{
var proj = new XamarinAndroidBindingProject {
Expand Down Expand Up @@ -556,6 +570,7 @@ public void BindDefaultInterfaceMethods (string classParser)
}

[Test]
[Category ("LibraryProjectZip")]
public void BugzillaBug11964 ()
{
var proj = new XamarinAndroidBindingProject ();
Expand Down
Loading

0 comments on commit 469a92d

Please sign in to comment.