Skip to content

Commit a9e1720

Browse files
committed
[tests] Remove Builder.UseDotNet
The .NET versus Classic switches have been removed from the MSBuild tests. Tests / asserts that only applied to classic have been removed. Test parameters that only applied to classic (`aapt` vs `aapt2`) have been removed. Some project properties that only applied to classic (`UseLatestPlatformSdk`) have been removed.
1 parent b1bb67b commit a9e1720

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+291
-1208
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ public void GetDependencyWhenBuildToolsAreMissingTest ()
133133
var referencesPath = CreateFauxReferencesDirectory (Path.Combine (path, "xbuild-frameworks"), apis);
134134
var proj = new XamarinAndroidApplicationProject () {
135135
IsRelease = true,
136-
TargetFrameworkVersion = "v8.0",
137136
TargetSdkVersion = "26",
138-
UseLatestPlatformSdk = false,
139137
};
140138
var parameters = new string [] {
141139
$"TargetFrameworkRootPath={referencesPath}",
@@ -147,7 +145,7 @@ public void GetDependencyWhenBuildToolsAreMissingTest ()
147145
builder.Target = "GetAndroidDependencies";
148146
Assert.True (builder.Build (proj, parameters: parameters),
149147
string.Format ("First Build should have succeeded"));
150-
int apiLevel = Builder.UseDotNet ? XABuildConfig.AndroidDefaultTargetDotnetApiLevel : 26;
148+
int apiLevel = XABuildConfig.AndroidDefaultTargetDotnetApiLevel;
151149
StringAssertEx.Contains ($"platforms/android-{apiLevel}", builder.LastBuildOutput, $"platforms/android-{apiLevel} should be a dependency.");
152150
StringAssertEx.Contains ($"build-tools/{buildToolsVersion}", builder.LastBuildOutput, $"build-tools/{buildToolsVersion} should be a dependency.");
153151
StringAssertEx.Contains ("platform-tools", builder.LastBuildOutput, "platform-tools should be a dependency.");
@@ -168,9 +166,7 @@ public void GetDependencyWhenSDKIsMissingTest ([Values (true, false)] bool creat
168166
var referencesPath = CreateFauxReferencesDirectory (Path.Combine (path, "xbuild-frameworks"), apis);
169167
var proj = new XamarinAndroidApplicationProject () {
170168
IsRelease = true,
171-
TargetFrameworkVersion = "v8.0",
172169
TargetSdkVersion = "26",
173-
UseLatestPlatformSdk = false,
174170
};
175171
var parameters = new string [] {
176172
$"TargetFrameworkRootPath={referencesPath}",
@@ -183,7 +179,7 @@ public void GetDependencyWhenSDKIsMissingTest ([Values (true, false)] bool creat
183179
builder.Target = "GetAndroidDependencies";
184180
Assert.True (builder.Build (proj, parameters: parameters),
185181
string.Format ("First Build should have succeeded"));
186-
int apiLevel = Builder.UseDotNet ? XABuildConfig.AndroidDefaultTargetDotnetApiLevel : 26;
182+
int apiLevel = XABuildConfig.AndroidDefaultTargetDotnetApiLevel;
187183
StringAssertEx.Contains ($"platforms/android-{apiLevel}", builder.LastBuildOutput, $"platforms/android-{apiLevel} should be a dependency.");
188184
StringAssertEx.Contains ($"build-tools/{buildToolsVersion}", builder.LastBuildOutput, $"build-tools/{buildToolsVersion} should be a dependency.");
189185
StringAssertEx.Contains ("platform-tools", builder.LastBuildOutput, "platform-tools should be a dependency.");

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs

Lines changed: 31 additions & 110 deletions
Large diffs are not rendered by default.

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ public void TearDown ()
5454

5555
void AssertProfiledAotBuildMessages(ProjectBuilder b)
5656
{
57-
string filename = Builder.UseDotNet ? "dotnet" : "startup";
58-
StringAssertEx.ContainsRegex (@$"Using profile data file.*{filename}\.aotprofile", b.LastBuildOutput, "Should use default AOT profile", RegexOptions.IgnoreCase);
57+
StringAssertEx.ContainsRegex (@$"Using profile data file.*dotnet\.aotprofile", b.LastBuildOutput, "Should use default AOT profile", RegexOptions.IgnoreCase);
5958
StringAssertEx.ContainsRegex (@$"Method.*emitted at", b.LastBuildOutput, "Should contain verbose AOT compiler output", RegexOptions.IgnoreCase);
6059
}
6160

6261
[Test, Category ("ProfiledAOT")]
6362
public void BuildBasicApplicationReleaseProfiledAot ([Values (true, false)] bool enableLLVM)
6463
{
65-
if (Builder.UseDotNet && enableLLVM) {
66-
Assert.Ignore("https://github.com/dotnet/runtime/pull/71411");
64+
if (TestEnvironment.IsWindows && enableLLVM) {
65+
Assert.Ignore("https://github.com/dotnet/runtime/issues/93788");
6766
}
6867

6968
var proj = new XamarinAndroidApplicationProject () {
@@ -108,8 +107,7 @@ public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile ()
108107
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseDefaultAotProfile", "false");
109108
using var b = CreateApkBuilder ();
110109
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
111-
string filename = Builder.UseDotNet ? "dotnet" : "startup";
112-
StringAssertEx.DoesNotContainRegex (@$"Using profile data file.*{filename}\.aotprofile", b.LastBuildOutput, "Should not use default AOT profile", RegexOptions.IgnoreCase);
110+
StringAssertEx.DoesNotContainRegex (@$"Using profile data file.*dotnet\.aotprofile", b.LastBuildOutput, "Should not use default AOT profile", RegexOptions.IgnoreCase);
113111
}
114112

115113
[Test]
@@ -199,31 +197,9 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb
199197
using (var b = CreateApkBuilder (path)) {
200198
b.ThrowOnBuildFailure = false;
201199
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
202-
//NOTE: Windows has shortened paths such as: C:\Users\myuser\ANDROI~3\ndk\PLATFO~1\AN3971~1\arch-x86\usr\lib\libc.so
203-
if (checkMinLlvmPath && !IsWindows && !Builder.UseDotNet) {
204-
Xamarin.Android.Tasks.NdkTools ndk = Xamarin.Android.Tasks.NdkTools.Create (AndroidNdkPath);
205-
bool ndk22OrNewer = ndk.Version.Main.Major >= 22;
206-
207-
// LLVM passes a direct path to libc.so, and we need to use the libc.so
208-
// which corresponds to the *minimum* SDK version specified in AndroidManifest.xml
209-
// Since we overrode minSdkVersion=16, that means we should use libc.so from android-16.
210-
if (ndk22OrNewer) {
211-
// NDK r22 or newer store libc in [toolchain]/sysroot/usr/lib/[ARCH]/[API]/libc.so
212-
StringAssertEx.ContainsRegex (@"\s*\[aot-compiler stdout].*sysroot.*.usr.lib.*19.libc\.so", b.LastBuildOutput, "AOT+LLVM should use libc.so from minSdkVersion!");
213-
} else {
214-
StringAssertEx.ContainsRegex (@"\s*\[aot-compiler stdout].*android-19.arch-.*.usr.lib.libc\.so", b.LastBuildOutput, "AOT+LLVM should use libc.so from minSdkVersion!");
215-
}
216-
}
217200
foreach (var abi in supportedAbis.Split (new char [] { ';' })) {
218201
var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
219-
if (!Builder.UseDotNet) {
220-
var libapp = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
221-
"bundles", abi, "libmonodroid_bundle_app.so");
222-
Assert.IsTrue (File.Exists (libapp), abi + " libmonodroid_bundle_app.so does not exist");
223-
}
224-
var aotNativeLibrary = Builder.UseDotNet ?
225-
Path.Combine (intermediate, AbiUtils.AbiToRuntimeIdentifier (abi), "aot", "UnnamedProject.dll.so") :
226-
Path.Combine (intermediate, "aot", abi, "libaot-UnnamedProject.dll.so");
202+
var aotNativeLibrary = Path.Combine (intermediate, AbiUtils.AbiToRuntimeIdentifier (abi), "aot", "UnnamedProject.dll.so");
227203
FileAssert.Exists (aotNativeLibrary);
228204
var apk = Path.Combine (Root, b.ProjectDirectory,
229205
proj.OutputPath, $"{proj.PackageName}-Signed.apk");
@@ -268,9 +244,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL
268244
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
269245
foreach (var abi in supportedAbis.Split (new char [] { ';' })) {
270246
var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
271-
var aotNativeLibrary = Builder.UseDotNet ?
272-
Path.Combine (intermediate, AbiUtils.AbiToRuntimeIdentifier (abi), "aot", "UnnamedProject.dll.so") :
273-
Path.Combine (intermediate, "aot", abi, "libaot-UnnamedProject.dll.so");
247+
var aotNativeLibrary = Path.Combine (intermediate, AbiUtils.AbiToRuntimeIdentifier (abi), "aot", "UnnamedProject.dll.so");
274248
FileAssert.Exists (aotNativeLibrary);
275249
var apk = Path.Combine (Root, b.ProjectDirectory,
276250
proj.OutputPath, $"{proj.PackageName}-Signed.apk");
@@ -304,19 +278,10 @@ public void BuildAMassiveApp ()
304278
SolutionPath = Path.Combine (Root, testPath),
305279
};
306280
var app1 = new XamarinFormsMapsApplicationProject {
307-
TargetFrameworkVersion = sb.LatestTargetFrameworkVersion (),
308281
ProjectName = "App1",
309282
AotAssemblies = true,
310283
IsRelease = true,
311284
};
312-
if (Builder.UseDotNet) {
313-
//TODO Re-enable if this test fails.
314-
// app1.PackageReferences.Clear ();
315-
// app1.PackageReferences.Add (KnownPackages.XamarinForms_5_0_0_2515);
316-
// app1.PackageReferences.Add (KnownPackages.XamarinFormsMaps_5_0_0_2515);
317-
// app1.PackageReferences.Add (KnownPackages.Xamarin_Build_Download_0_11_3);
318-
319-
}
320285
//NOTE: BuildingInsideVisualStudio prevents the projects from being built as dependencies
321286
sb.BuildingInsideVisualStudio = false;
322287
app1.Imports.Add (new Import ("foo.targets") {
@@ -348,7 +313,6 @@ public void BuildAMassiveApp ()
348313
for (int i = 0; i < 128; i++) {
349314
var libName = $"Lib{i}";
350315
var lib = new XamarinAndroidLibraryProject () {
351-
TargetFrameworkVersion = sb.LatestTargetFrameworkVersion (),
352316
ProjectName = libName,
353317
IsRelease = true,
354318
OtherBuildItems = {
@@ -482,13 +446,8 @@ public void CheckWhetherLibcAndLibmAreReferencedInAOTLibraries ()
482446
proj.SetAndroidSupportedAbis (abis);
483447

484448
var libPaths = new List<string> ();
485-
if (Builder.UseDotNet) {
486-
libPaths.Add (Path.Combine ("android-arm64", "aot", "Mono.Android.dll.so"));
487-
libPaths.Add (Path.Combine ("android-x64", "aot", "Mono.Android.dll.so"));
488-
} else {
489-
libPaths.Add (Path.Combine ("aot", "arm64-v8a", "libaot-Mono.Android.dll.so"));
490-
libPaths.Add (Path.Combine ("aot", "x86_64", "libaot-Mono.Android.dll.so"));
491-
}
449+
libPaths.Add (Path.Combine ("android-arm64", "aot", "Mono.Android.dll.so"));
450+
libPaths.Add (Path.Combine ("android-x64", "aot", "Mono.Android.dll.so"));
492451

493452
using (var b = CreateApkBuilder ()) {
494453
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,8 @@ public void BindingLibraryIncremental (string classParser)
7474
"GenerateBindings",
7575
"_ResolveLibraryProjectImports",
7676
"CoreCompile",
77+
"_CreateAar",
7778
};
78-
if (Builder.UseDotNet) {
79-
targets.Add ("_CreateAar");
80-
} else {
81-
targets.Add ("_CreateBindingResourceArchive");
82-
//TODO: .NET 5+ cannot support javadoc yet, due to missing mdoc
83-
targets.Add ("_ExtractJavaDocJars");
84-
targets.Add ("BuildDocumentation");
85-
}
8679

8780
var proj = new XamarinAndroidBindingProject () {
8881
IsRelease = true,
@@ -102,7 +95,7 @@ public void BindingLibraryIncremental (string classParser)
10295
}
10396

10497
//TODO: see https://github.com/dotnet/msbuild/issues/6609
105-
if (!Builder.UseDotNet) {
98+
if (false) {
10699
//A list of properties we check exist in binding projects
107100
var properties = new [] {
108101
"AndroidSdkBuildToolsVersion",
@@ -155,7 +148,6 @@ public void CleanBasicBindingLibrary (string classParser)
155148
public void BuildAarBindingLibraryStandalone (string classParser)
156149
{
157150
var proj = new XamarinAndroidBindingProject () {
158-
UseLatestPlatformSdk = true,
159151
IsRelease = true,
160152
};
161153
proj.Jars.Add (new AndroidItem.AndroidLibrary ("Jars\\material-menu-1.1.0.aar") {
@@ -164,9 +156,7 @@ public void BuildAarBindingLibraryStandalone (string classParser)
164156
proj.AndroidClassParser = classParser;
165157
using (var b = CreateDllBuilder ()) {
166158
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
167-
if (Builder.UseDotNet) {
168-
FileAssert.Exists (Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, "material-menu-1.1.0.aar"));
169-
}
159+
FileAssert.Exists (Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, "material-menu-1.1.0.aar"));
170160
}
171161
}
172162

@@ -175,7 +165,6 @@ public void BuildAarBindingLibraryStandalone (string classParser)
175165
public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser)
176166
{
177167
var proj = new XamarinAndroidBindingProject () {
178-
UseLatestPlatformSdk = true,
179168
IsRelease = true,
180169
};
181170
proj.PackageReferences.Add (KnownPackages.AndroidSupportV4_27_0_2_1);
@@ -201,7 +190,6 @@ public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser)
201190
public void BuildLibraryZipBindigLibraryWithAarOfJar (string classParser)
202191
{
203192
var proj = new XamarinAndroidBindingProject () {
204-
UseLatestPlatformSdk = true,
205193
IsRelease = true,
206194
};
207195
proj.AndroidClassParser = classParser;
@@ -398,15 +386,13 @@ public void BindingCheckHiddenFiles ()
398386
FileAssert.Exists (assemblyMap);
399387
var libraryProjects = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "lp");
400388
var assemblyIdentityMap = b.Output.GetAssemblyMapCache ();
401-
var assemblyIdentityName = Builder.UseDotNet ? "mylibrary.aar" : $"{binding.ProjectName}.dll";
389+
var assemblyIdentityName = "mylibrary.aar";
402390
var assemblyIdentity = assemblyIdentityMap.IndexOf (assemblyIdentityName).ToString ();
403391
var dsStorePath = Path.Combine (libraryProjects, assemblyIdentity, "jl");
404392
DirectoryAssert.Exists (dsStorePath);
405393
FileAssert.DoesNotExist (Path.Combine (dsStorePath, ".DS_Store"));
406394
DirectoryAssert.DoesNotExist (Path.Combine (dsStorePath, "_MACOSX"));
407-
var svgJar = Builder.UseDotNet ?
408-
Path.Combine (libraryProjects, assemblyIdentityMap.IndexOf ($"{binding.ProjectName}.aar").ToString (), "jl", "libs", "FD575F2BC294C4A9.jar") :
409-
Path.Combine (dsStorePath, "svg-android.jar");
395+
var svgJar = Path.Combine (libraryProjects, assemblyIdentityMap.IndexOf ($"{binding.ProjectName}.aar").ToString (), "jl", "libs", "FD575F2BC294C4A9.jar");
410396
FileAssert.Exists (svgJar);
411397
}
412398
}
@@ -651,7 +637,6 @@ public void BindDefaultInterfaceMethods (string classParser)
651637
proj.SetProperty ("LangVersion", "preview");
652638

653639
using (var b = CreateDllBuilder ()) {
654-
proj.NuGetRestore (b.ProjectDirectory);
655640
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
656641

657642
string asmpath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.ProjectName}.dll");
@@ -681,8 +666,6 @@ public void NothingToBind (string classParser)
681666
[Test]
682667
public void BindingWithAndroidJavaSource ()
683668
{
684-
if (!Builder.UseDotNet)
685-
Assert.Ignore ("This Feature and Test is not available in Legacy Projects");
686669
var path = Path.Combine ("temp", TestName);
687670
var lib = new XamarinAndroidBindingProject () {
688671
ProjectName = "BindingsProject",
@@ -732,10 +715,7 @@ public void BindingWithAndroidJavaSource ()
732715
var hash = Files.HashString (Path.Combine (lib.IntermediateOutputPath,
733716
"binding", "bin", $"{lib.ProjectName}.jar").Replace ("\\", "/"));
734717
var intermediate = Path.Combine (Root, appBuilder.ProjectDirectory, app.IntermediateOutputPath);
735-
var lpPath = Path.Combine ("0", "jl", $"{lib.ProjectName}.jar");
736-
if (Builder.UseDotNet) {
737-
lpPath = Path.Combine ("1", "jl", "libs", $"{hash}.jar");
738-
}
718+
var lpPath = Path.Combine ("1", "jl", "libs", $"{hash}.jar");
739719
var jar = Path.Combine (intermediate, "lp", lpPath);
740720
FileAssert.Exists (jar, $"'{jar}' should have been generated.");
741721
var dexFile = Path.Combine (intermediate, "android", "bin", "classes.dex");

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ public void CheckPostCompileAssetsIncludedInAPK ()
5858
}
5959

6060
[Test]
61-
public void CheckAssetsAreIncludedInAPK ([Values (true, false)] bool useAapt2)
61+
public void CheckAssetsAreIncludedInAPK ()
6262
{
63-
AssertAaptSupported (useAapt2);
6463
var projectPath = Path.Combine ("temp", TestName);
6564
var libproj = new XamarinAndroidLibraryProject () {
6665
ProjectName = "Library1",
@@ -106,7 +105,6 @@ public void CheckAssetsAreIncludedInAPK ([Values (true, false)] bool useAapt2)
106105
},
107106
}
108107
};
109-
proj.AndroidUseAapt2 = useAapt2;
110108
proj.References.Add (new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj"));
111109
using (var libb = CreateDllBuilder (Path.Combine (projectPath, libproj.ProjectName))) {
112110
Assert.IsTrue (libb.Build (libproj), "{0} should have built successfully.", libproj.ProjectName);
@@ -151,19 +149,12 @@ public void FullPath ()
151149
using (var b = CreateDllBuilder (Path.Combine ("temp", TestName, "SubDir"))) {
152150
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
153151
var libraryProjectImports = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "__AndroidLibraryProjects__.zip");
154-
if (Builder.UseDotNet) {
155-
var aarPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.ProjectName}.aar");
156-
FileAssert.Exists (aarPath);
157-
using (var aar = ZipHelper.OpenZip (aarPath)) {
158-
aar.AssertEntryContents (aarPath, "assets/foo.txt", contents: "bar");
159-
}
160-
FileAssert.DoesNotExist (libraryProjectImports);
161-
} else {
162-
FileAssert.Exists (libraryProjectImports);
163-
using (var zip = ZipHelper.OpenZip (libraryProjectImports)) {
164-
zip.AssertEntryContents (libraryProjectImports, "library_project_imports/assets/foo.txt", contents: "bar");
165-
}
152+
var aarPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.ProjectName}.aar");
153+
FileAssert.Exists (aarPath);
154+
using (var aar = ZipHelper.OpenZip (aarPath)) {
155+
aar.AssertEntryContents (aarPath, "assets/foo.txt", contents: "bar");
166156
}
157+
FileAssert.DoesNotExist (libraryProjectImports);
167158
}
168159
}
169160
}

0 commit comments

Comments
 (0)