From 7e08fd6ddabcb23820e160cf9809ef05609929e6 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 16 Jan 2026 11:27:33 +0100 Subject: [PATCH] [tests] Delete most legacy msbuild tests. --- tests/common/ConfigurationNUnit.cs | 4 - .../TaskTests/DetectSdkLocationsTaskTests.cs | 16 - .../GeneratePlistTaskTests_Core.cs | 2 - .../TaskTests/MergeAppBundleTaskTest.cs | 1 - .../Xamarin.MacDev.Tests/MSBuild-Smoke.cs | 287 -------- .../ProjectsTests/BindingReferences.cs | 44 -- .../ProjectsTests/Bug60536.cs | 64 -- .../ProjectsTests/CodesignAppBundle.cs | 153 ----- .../CompileSceneKitAssetsTest.cs | 52 -- .../ProjectsTests/CoreMLCompiler.cs | 60 -- .../ProjectsTests/EmbeddedExtension.cs | 59 -- .../ProjectsTests/Extensions/Action.cs | 23 - .../Extensions/CustomKeyboard.cs | 32 - .../Extensions/DocumentPicker.cs | 26 - .../Extensions/ExtensionTestBase.cs | 63 -- .../ProjectsTests/Extensions/PhotoEditing.cs | 24 - .../ProjectsTests/Extensions/Share.cs | 24 - .../ProjectsTests/Extensions/Today.cs | 24 - .../ProjectsTests/IBToolLinking.cs | 23 - .../ProjectsTests/LinkedAssets.cs | 33 - .../ProjectsTests/NativeReferences.cs | 76 --- .../NativeReferencesNoEmbedding.cs | 126 ---- .../ProjectsTests/ProjectReference.cs | 36 - .../ProjectsTests/ProjectTest.cs | 90 --- .../ProjectsTests/ProjectWithFrameworks.cs | 30 - .../ProjectsTests/ProjectWithSpaces.cs | 33 - .../ProjectsTests/ReleaseBuild.cs | 97 --- .../ProjectsTests/ResponseFileArguments.cs | 25 - .../ProjectsTests/SystemMemoryReference.cs | 49 -- .../ProjectsTests/TVOS/TVApp.cs | 31 - .../ProjectsTests/TVOS/TVMetalGameTests.cs | 31 - .../ProjectsTests/XamarinForms.cs | 40 -- .../Xamarin.MacDev.Tests/RoslynSmokeTests.cs | 40 -- .../Xamarin.MacDev.Tests/RuntimeTests.cs | 27 - .../TargetTests/CollectAppManifestsTests.cs | 3 +- .../TargetTests/DetectSigningIdentityTests.cs | 3 +- .../TargetTests/TargetTests.cs | 632 +----------------- .../TargetTests/ValidateAppBundleTaskTests.cs | 89 --- .../TestHelpers/BuildEngine.cs | 15 +- .../TestHelpers/ExecutionMode.cs | 9 - .../TestHelpers/TestBase.cs | 105 +-- 41 files changed, 16 insertions(+), 2585 deletions(-) delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/MSBuild-Smoke.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/BindingReferences.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Bug60536.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CodesignAppBundle.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CompileSceneKitAssetsTest.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CoreMLCompiler.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/EmbeddedExtension.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Action.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/CustomKeyboard.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/DocumentPicker.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/PhotoEditing.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Share.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Today.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/IBToolLinking.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/LinkedAssets.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferences.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectReference.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithFrameworks.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithSpaces.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ReleaseBuild.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ResponseFileArguments.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/SystemMemoryReference.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVApp.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVMetalGameTests.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/XamarinForms.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/RoslynSmokeTests.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/RuntimeTests.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/TargetTests/ValidateAppBundleTaskTests.cs delete mode 100644 tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/ExecutionMode.cs diff --git a/tests/common/ConfigurationNUnit.cs b/tests/common/ConfigurationNUnit.cs index 39e01d8bbc26..43a82b38bb15 100644 --- a/tests/common/ConfigurationNUnit.cs +++ b/tests/common/ConfigurationNUnit.cs @@ -44,10 +44,6 @@ public static void AssertiOS32BitAvailable () } #endif // !XAMMAC_TESTS - public static void AssertDotNetAvailable () - { - } - public static void AssertLegacyXamarinAvailable () { Assert.Ignore ("Legacy xamarin build not enabled"); diff --git a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/DetectSdkLocationsTaskTests.cs b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/DetectSdkLocationsTaskTests.cs index 6652107d88d4..0c800c482d84 100644 --- a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/DetectSdkLocationsTaskTests.cs +++ b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/DetectSdkLocationsTaskTests.cs @@ -20,21 +20,5 @@ public void InvalidXamarinSdkRoot () Assert.AreEqual ("XYZ", task.XamarinSdkRoot, "#1"); } - - [Test] - public void InexistentSDKVersion () - { - Configuration.AssertLegacyXamarinAvailable (); - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - var task = CreateTask (); - task.SdkVersion = "4.0"; - task.TargetFrameworkMoniker = TargetFramework.DotNet_iOS_String; - Assert.IsTrue (task.Execute (), "4.0 Execute"); - - Assert.AreNotEqual ("4.0", task.SdkVersion, "#1"); - - task.SdkVersion = "44.0"; - Assert.IsFalse (task.Execute (), "44.0 Execute"); - } } } diff --git a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs index d2dbcb91a68b..d9f74ada78b4 100644 --- a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs +++ b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs @@ -57,8 +57,6 @@ public override void Setup () { base.Setup (); - Configuration.AssertDotNetAvailable (); - ConfigureTask (); ExecuteTask (Task); diff --git a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/MergeAppBundleTaskTest.cs b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/MergeAppBundleTaskTest.cs index 16a79e70fb84..5de6034ab629 100644 --- a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/MergeAppBundleTaskTest.cs +++ b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/MergeAppBundleTaskTest.cs @@ -113,7 +113,6 @@ public void TestLipoExecutable () [Test] public void TestPEAssembly () { - Configuration.AssertDotNetAvailable (); var complexAssemblyPath = Path.Combine (Configuration.RootPath, "tests", "common", "TestProjects", "ComplexAssembly", "bin", "Debug", Configuration.DotNetTfm); var complexFiles = new string [] { "ComplexAssembly.dll", diff --git a/tests/msbuild/Xamarin.MacDev.Tests/MSBuild-Smoke.cs b/tests/msbuild/Xamarin.MacDev.Tests/MSBuild-Smoke.cs deleted file mode 100644 index b4646b439ff2..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/MSBuild-Smoke.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using NUnit.Framework; - -using Xamarin; -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MMP.Tests { - [TestFixture] - public partial class MMPTests { - void RunMSBuildTest (Action test, string directory_name = null) - { - test (Cache.CreateTemporaryDirectory (directory_name ?? "msbuild-tests")); - } - - [Test] - public void BuildUnifiedMobile_Program_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = "UnifiedExample.csproj" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildUnifiedXM45_Program_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = "XM45Example.csproj" }); - TI.BuildProject (projectPath); - }); - } - - void TestBCLCore (string tmpDir, string projectName) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - var dll = Path.GetFullPath (Path.Combine (TI.TestDirectory, "common", "mac", "System.Collections.Immutable.dll")); - string reference = $"{dll}"; - string testCode = "var v = System.Collections.Immutable.ImmutableArray.CreateRange (new int [] { 42 });"; - string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = projectName, References = reference, TestCode = testCode }); - TI.BuildProject (projectPath); - } - - [Test] - public void BuildUnifiedMobile_Program_WithBCL () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - TestBCLCore (tmpDir, "UnifiedExample.csproj"); - }); - } - - [Test] - public void BuildUnifiedXM45_Program_WithBCL () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - TestBCLCore (tmpDir, "XM45Example.csproj"); - }); - } - - [Test] - public void BuildFSharpUnifiedMobile_Program_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { FSharp = true, ProjectName = "FSharpUnifiedExample.fsproj" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildFSharpUnifiedXM45_Program_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { FSharp = true, ProjectName = "FSharpXM45Example.fsproj" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildUnifiedMobile_Library_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateUnifiedLibraryProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = "UnifiedLibrary" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildUnifiedXM45_Library_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateUnifiedLibraryProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = "XM45Library" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildFSharpUnifiedMobile_Library_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateUnifiedLibraryProject (new TI.UnifiedTestConfig (tmpDir) { FSharp = true, ProjectName = "FSharpUnifiedLibrary" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildFSharpUnifiedXM45_Library_SmokeTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - string projectPath = TI.GenerateUnifiedLibraryProject (new TI.UnifiedTestConfig (tmpDir) { FSharp = true, ProjectName = "FSharpXM45Library" }); - TI.BuildProject (projectPath); - }); - } - - [Test] - public void BuildUnifiedProject_WithJustNativeRefNoLinkWith_Builds () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - var dylib = Path.GetFullPath (Path.Combine (TI.TestDirectory, "test-libraries", ".libs", "macos", "libframework.dylib")); - string itemGroup = $" FalseDynamic "; - string projectPath = TI.GenerateEXEProject (new TI.UnifiedTestConfig (tmpDir) { ProjectName = "UnifiedExample.csproj", ItemGroup = itemGroup }); - var testResults = TI.BuildProject (projectPath); - testResults.Messages.AssertNoMessage (2006); - Assert.That (Path.Combine (tmpDir, $"bin", "Debug", "UnifiedExample.app", "Contents", "MonoBundle", Path.GetFileName (dylib)), Does.Exist, "dylib in app"); - - Assert.AreEqual (0, ExecutionHelper.Execute ("/usr/bin/otool", new [] { "-L", Path.Combine (tmpDir, "bin/Debug/UnifiedExample.app/Contents/MacOS/UnifiedExample") }, out var output)); - Assert.IsTrue (output.ToString ().Contains (Path.GetFileName (dylib))); - }); - } - - [Test] - [TestCase ("XM45Binding.csproj")] - [TestCase ("MobileBinding.csproj")] - [TestCase ("BindingProjectWithNoTag.csproj")] - public void Build_BindingLibrary_SmokeTest (string projectName) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { ProjectName = projectName }; - string projectPath = TI.GenerateBindingLibraryProject (test); - TI.BuildProject (projectPath); - }); - } - - [Test] - [TestCase ("XM45Binding.csproj")] - [TestCase ("MobileBinding.csproj")] - [TestCase ("BindingProjectWithNoTag.csproj")] - public void BuildingSameBindingProject_TwoTimes_ShallNotInvokeMMPTwoTimes (string project) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var dylib = Path.GetFullPath (Path.Combine (TI.TestDirectory, "test-libraries", ".libs", "macos", "libframework.dylib")); - string nativeRefItemGroup = $"DynamicFalse"; - - RunMSBuildTest (tmpDir => { - var config = new TI.UnifiedTestConfig (tmpDir) { ProjectName = project, ItemGroup = nativeRefItemGroup }; - string projectPath = TI.GenerateBindingLibraryProject (config); - string buildOutput = TI.BuildProject (projectPath).BuildOutput; - Assert.IsTrue (buildOutput.Contains (@"Building target ""CoreCompile""")); - - string secondBuildOutput = TI.BuildProject (projectPath).BuildOutput; - Assert.IsFalse (secondBuildOutput.Contains (@"Building target ""CoreCompile""")); - }); - } - - [Test] - [TestCase ("UnifiedExample.csproj")] - [TestCase ("XM45Example.csproj")] - public void BuildingSameProject_TwoTimes_ShallNotInvokeMMPTwoTimes (string project) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunMSBuildTest (tmpDir => { - var config = new TI.UnifiedTestConfig (tmpDir) { ProjectName = project }; - string projectPath = TI.GenerateEXEProject (config); - string buildOutput = TI.BuildProject (projectPath).BuildOutput; - Assert.IsTrue (buildOutput.Contains (@"Building target ""_CompileToNative""")); - - string secondBuildOutput = TI.BuildProject (projectPath).BuildOutput; - Assert.IsFalse (secondBuildOutput.Contains (@"Building target ""_CompileToNative""")); - }); - } - - [Test] - public void MyCocoaSceneKitApp () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var projectPath = Path.Combine (Configuration.TestProjectsDirectory, "MyCocoaSceneKitApp", "MyCocoaSceneKitApp.csproj"); - // Clone the project directory to a temporary directory - var testDirectory = Configuration.CloneTestDirectory (Path.GetDirectoryName (projectPath)); - // Update the project path to the clone project path in the temporary directory - projectPath = Path.Combine (testDirectory, Path.GetFileName (projectPath)); - // build the project - TI.BuildProject (projectPath); - // verify that the scene kit assets are present in the app - var resourceDir = Path.Combine (testDirectory, "bin", "Debug", "MyCocoaSceneKitApp.app", "Contents", "Resources"); - Assert.That (Path.Combine (resourceDir, "art.scnassets", "scene.scn"), Does.Exist, "scene.scn"); - Assert.That (Path.Combine (resourceDir, "art.scnassets", "texture.png"), Does.Exist, "texture.png"); - } - - [Test] - public void MyCocoaCoreMLApp () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var projectPath = Path.Combine (Configuration.TestProjectsDirectory, "MyCocoaCoreMLApp", "MyCocoaCoreMLApp.csproj"); - // Clone the project directory to a temporary directory - var testDirectory = Configuration.CloneTestDirectory (Path.GetDirectoryName (projectPath)); - // Update the project path to the clone project path in the temporary directory - projectPath = Path.Combine (testDirectory, Path.GetFileName (projectPath)); - // build the project - TI.BuildProject (projectPath); - // verify that the scene kit assets are present in the app - var resourceDir = Path.Combine (testDirectory, "bin", "Debug", "MyCocoaCoreMLApp.app", "Contents", "Resources"); - AssertCompiledModelExists (resourceDir, "SqueezeNet"); - } - - void AssertCompiledModelExists (string appBundlePath, string modelName) - { - var expected = new string [] { "coremldata.bin", "model.espresso.net", "model.espresso.shape", "model.espresso.weights", "model/coremldata.bin", "neural_network_optionals/coremldata.bin" }; - var mlmodelc = Path.Combine (appBundlePath, modelName + ".mlmodelc"); - - Assert.IsTrue (Directory.Exists (mlmodelc), "mlmodelc existence"); - - var files = new HashSet (Directory.EnumerateFiles (mlmodelc, "*.*", SearchOption.AllDirectories)); - - foreach (var name in expected) - Assert.IsTrue (files.Contains (Path.Combine (mlmodelc, name)), "{0} not found", name); - - var expected_length = expected.Length; - if (Configuration.XcodeVersion.Major >= 12) { - Assert.IsTrue (files.Contains (Path.Combine (mlmodelc, "metadata.json")), " metadata.json not found"); - expected_length++; - Assert.IsTrue (files.Contains (Path.Combine (mlmodelc, "analytics", "coremldata.bin")), "analytics/coremldata.bin not found"); - expected_length++; - } - Assert.AreEqual (expected_length, files.Count, "File count"); - } - - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/BindingReferences.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/BindingReferences.cs deleted file mode 100644 index 76e050b51237..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/BindingReferences.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.IO; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - public class BindingReferences : TestBase { - - [Test] - public void BuildTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var projA = SetupProjectPaths ("MyBindingsReferences/LibraryA"); - var dllAPath = Path.Combine (projA.ProjectBinPath, "LibraryA.dll"); - - RunTarget (projA, "Build", 0); - Assert.IsTrue (File.Exists (dllAPath), "LibraryA dll does not exist: {0} ", dllAPath); - - var projB = SetupProjectPaths ("MyBindingsReferences/LibraryB"); - var dllBPath = Path.Combine (projB.ProjectBinPath, "LibraryB.dll"); - - RunTarget (projB, "Build", 0); - Assert.IsTrue (File.Exists (dllBPath), "LibraryB binding dll does not exist: {0} ", dllBPath); - } - - // https://bugzilla.xamarin.com/show_bug.cgi?id=56317 - [Test] - public void SatelliteAssembliesBug () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var proj = SetupProjectPaths ("MySatelliteAssembliesBug/iOSBinding"); - var dll = Path.Combine (proj.ProjectBinPath, "iOSBinding.dll"); - - RunTarget (proj, "Build", 0); - Assert.IsTrue (File.Exists (dll), "iOSBinding dll does not exist: {0} ", dll); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Bug60536.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Bug60536.cs deleted file mode 100644 index 2a27c1a86661..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Bug60536.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Collections; - -using Microsoft.Build.Evaluation; - -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture] - public class Bug60536 : ProjectTest { - public Bug60536 () - : base ("iPhoneSimulator", "Debug") - { - } - - [Test] - public void TestACToolTaskCatchesJsonException () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var project = SetupProjectPaths ("Bug60536"); - var csproj = project.ProjectCSProjPath; - - MonoTouchProject = project; - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - Engine.ProjectCollection.SetGlobalProperty ("Configuration", Config); - - RunTarget (project, "Clean"); - Assert.IsFalse (Directory.Exists (AppBundlePath), "App bundle exists after cleanup: {0} ", AppBundlePath); - Assert.IsFalse (Directory.Exists (AppBundlePath + ".dSYM"), "App bundle .dSYM exists after cleanup: {0} ", AppBundlePath + ".dSYM"); - Assert.IsFalse (Directory.Exists (AppBundlePath + ".mSYM"), "App bundle .mSYM exists after cleanup: {0} ", AppBundlePath + ".mSYM"); - - var baseDir = Path.GetDirectoryName (csproj); - var objDir = Path.Combine (baseDir, "obj", Platform, Config); - var binDir = Path.Combine (baseDir, "bin", Platform, Config); - - if (Directory.Exists (objDir)) { - var path = Directory.EnumerateFiles (objDir, "*.*", SearchOption.AllDirectories).FirstOrDefault (); - Assert.IsNull (path, "File not cleaned: {0}", path); - } - - if (Directory.Exists (binDir)) { - var path = Directory.EnumerateFiles (binDir, "*.*", SearchOption.AllDirectories).FirstOrDefault (); - Assert.IsNull (path, "File not cleaned: {0}", path); - } - - RunTarget (MonoTouchProject, "Build", expectedErrorCount: 1); - - var expectedFile = Path.Combine ("Assets.xcassets", "AppIcon.appiconset", "Contents.json"); - Assert.AreEqual (expectedFile, Engine.Logger.ErrorEvents [0].File, "File"); - Assert.AreEqual (197, Engine.Logger.ErrorEvents [0].LineNumber, "LineNumber"); - Assert.AreEqual (4, Engine.Logger.ErrorEvents [0].ColumnNumber, "ColumnNumber"); - Assert.AreEqual (197, Engine.Logger.ErrorEvents [0].EndLineNumber, "EndLineNumber"); - Assert.AreEqual (4, Engine.Logger.ErrorEvents [0].EndColumnNumber, "EndColumnNumber"); - Assert.AreEqual ("']' is invalid without a matching open. LineNumber: 196 | BytePositionInLine: 3.", Engine.Logger.ErrorEvents [0].Message, "Message"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CodesignAppBundle.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CodesignAppBundle.cs deleted file mode 100644 index 0c2e060943a6..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CodesignAppBundle.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Diagnostics; -using System.Collections.Generic; - -using NUnit.Framework; - -using Xamarin.MacDev; -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone", "Debug")] - [TestFixture ("iPhone", "Release")] - // Note: Disabled because Simulator builds aren't consistently signed or not-signed, while device builds are. - //[TestFixture ("iPhoneSimulator", "Debug")] - //[TestFixture ("iPhoneSimulator", "Release")] - public class CodesignAppBundle : ProjectTest { - public CodesignAppBundle (string platform, string configuration) - : base (platform, configuration) - { - } - - static bool IsCodesigned (string path) - { - var psi = new ProcessStartInfo ("/usr/bin/codesign"); - var args = new List (); - - args.Add ("--verify"); - args.Add (path); - - foreach (var arg in args) - psi.ArgumentList.Add (arg); - - var process = Process.Start (psi); - process.WaitForExit (); - - return process.ExitCode == 0; - } - - void AssertProperlyCodesigned (bool expected) - { - foreach (var dylib in Directory.EnumerateFiles (AppBundlePath, "*.dylib", SearchOption.AllDirectories)) - Assert.AreEqual (expected, IsCodesigned (dylib), "{0} is not properly codesigned.", dylib); - - foreach (var appex in Directory.EnumerateDirectories (AppBundlePath, "*.appex", SearchOption.AllDirectories)) - Assert.AreEqual (expected, IsCodesigned (appex), "{0} is not properly codesigned.", appex); - } - - [Test] - public void RebuildNoChanges () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - bool expectedCodesignResults = Platform != "iPhoneSimulator"; - - BuildProject ("MyTabbedApplication"); - - AssertProperlyCodesigned (expectedCodesignResults); - - var dsymDir = Path.GetFullPath (Path.Combine (AppBundlePath, "..", "MyTabbedApplication.app.dSYM")); - var appexDsymDir = Path.GetFullPath (Path.Combine (AppBundlePath, "..", "MyActionExtension.appex.dSYM")); - - var timestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.TopDirectoryOnly).ToDictionary (file => file, file => GetLastModified (file)); - Dictionary dsymTimestamps = null, appexDsymTimestamps = null; - - if (Platform != "iPhoneSimulator") { - dsymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - appexDsymTimestamps = Directory.EnumerateFiles (appexDsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - } - - EnsureFilestampChange (); - - // Rebuild w/ no changes - BuildProject ("MyTabbedApplication", clean: false); - - AssertProperlyCodesigned (expectedCodesignResults); - - var newTimestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.TopDirectoryOnly).ToDictionary (file => file, file => GetLastModified (file)); - - foreach (var file in timestamps.Keys) { - // The executable files will all be newer because they get touched during each Build, all other files should not change - if (Path.GetFileName (file) == "MyTabbedApplication" || Path.GetExtension (file) == ".dylib") - continue; - - Assert.AreEqual (timestamps [file], newTimestamps [file], "App Bundle timestamp changed: " + file); - } - - if (Platform != "iPhoneSimulator") { - var newDsymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - var newAppexDsymTimestamps = Directory.EnumerateFiles (appexDsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - - foreach (var file in dsymTimestamps.Keys) { - // The Info.plist should be newer because it gets touched - if (Path.GetFileName (file) == "Info.plist") { - Assert.IsTrue (dsymTimestamps [file] < newDsymTimestamps [file], "App Bundle dSYMs Info.plist not touched: " + file); - } else { - Assert.AreEqual (dsymTimestamps [file], newDsymTimestamps [file], "App Bundle dSYMs changed: " + file); - } - } - - // The appex dSYMs will all be newer because they currently get regenerated after each Build due to the fact that the entire - // *.appex gets cloned into the app bundle each time. - // - // Note: we could fix this by not using `ditto` and instead implementing this ourselves to only overwrite files if they've changed - // and then setting some [Output] params that specify whether or not we need to re-codesign and/or strip debug symbols. - foreach (var file in appexDsymTimestamps.Keys) - Assert.IsTrue (appexDsymTimestamps [file] < newAppexDsymTimestamps [file], "App Extension dSYMs should be newer: " + file); - } - } - - [Test] - public void CodesignAfterModifyingAppExtensionTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var csproj = BuildProject ("MyTabbedApplication", clean: true).ProjectCSProjPath; - var testsDir = Path.GetDirectoryName (Path.GetDirectoryName (csproj)); - var appexProjectDir = Path.Combine (testsDir, "MyActionExtension"); - var viewController = Path.Combine (appexProjectDir, "ActionViewController.cs"); - var mainExecutable = Path.Combine (AppBundlePath, "MyTabbedApplication"); - bool expectedCodesignResults = Platform != "iPhoneSimulator"; - var timestamp = File.GetLastWriteTimeUtc (mainExecutable); - var text = File.ReadAllText (viewController); - - AssertProperlyCodesigned (expectedCodesignResults); - - EnsureFilestampChange (); - - // replace "bool imageFound = false;" with "bool imageFound = true;" so that we force the appex to get rebuilt - text = text.Replace ("bool imageFound = false;", "bool imageFound = true;"); - File.WriteAllText (viewController, text); - - try { - BuildProject ("MyTabbedApplication", clean: false); - var newTimestamp = File.GetLastWriteTimeUtc (mainExecutable); - - // make sure that the main app bundle was codesigned due to the changes in the appex - Assert.AreEqual (expectedCodesignResults, newTimestamp > timestamp, "The main app bundle does not seem to have been re-codesigned"); - - AssertProperlyCodesigned (expectedCodesignResults); - } finally { - // restore the original ActionViewController.cs code... - text = text.Replace ("bool imageFound = true;", "bool imageFound = false;"); - File.WriteAllText (viewController, text); - } - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CompileSceneKitAssetsTest.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CompileSceneKitAssetsTest.cs deleted file mode 100644 index de004acd7dc2..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CompileSceneKitAssetsTest.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Diagnostics; -using System.Collections.Generic; - -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - // [TestFixture ("iPhone")] // Skip this to speed things up a bit. - [TestFixture ("iPhoneSimulator")] - public class CompileSceneKitAssetsTest : ProjectTest { - public CompileSceneKitAssetsTest (string platform) : base (platform) - { - } - - [Test] - public void Compilation () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var proj = BuildProject ("MySceneKitApp"); - var appPath = proj.AppBundlePath; - var scenePath = Path.GetFullPath (Path.Combine (appPath, "art.scnassets", "scene.scn")); - - var xml = Configuration.ReadPListAsXml (scenePath); - Assert.That (xml, Does.Contain ("art.scnassets/texture.png"), "asset with path"); - } - - [Test] - public void LibraryCompilation () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var appName = "MySceneKitLibrary"; - - Platform = "AnyCPU"; - var proj = SetupProjectPaths (appName); - - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - Engine.ProjectCollection.SetGlobalProperty ("Configuration", Config); - - RunTarget (proj, "Build", 0); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CoreMLCompiler.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CoreMLCompiler.cs deleted file mode 100644 index d649c37d88c3..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/CoreMLCompiler.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.IO; -using System.Linq; -using System.Threading; -using System.Diagnostics; -using System.Collections.Generic; - -using Xamarin.Tests; -using Xamarin.Utils; - -using NUnit.Framework; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class CoreMLCompiler : ProjectTest { - public CoreMLCompiler (string platform) : base (platform) - { - } - - void AssertCompiledModelExists (string modelName) - { - var expected = new string [] { "coremldata.bin", "model.espresso.net", "model.espresso.shape", "model.espresso.weights", "model/coremldata.bin", "neural_network_optionals/coremldata.bin" }; - var mlmodelc = Path.Combine (AppBundlePath, modelName + ".mlmodelc"); - - Assert.IsTrue (Directory.Exists (mlmodelc)); - - var files = new HashSet (Directory.EnumerateFiles (mlmodelc, "*.*", SearchOption.AllDirectories)); - - foreach (var name in expected) - Assert.IsTrue (files.Contains (Path.Combine (mlmodelc, name)), "{0} not found", name); - - var expected_length = expected.Length; - if (Configuration.XcodeVersion.Major >= 12) { - Assert.IsTrue (files.Contains (Path.Combine (mlmodelc, "metadata.json")), " metadata.json not found"); - expected_length++; - Assert.IsTrue (files.Contains (Path.Combine (mlmodelc, "analytics", "coremldata.bin")), "analytics/coremldata.bin not found"); - expected_length++; - } - Assert.AreEqual (expected_length, files.Count, "File count"); - } - - [Test] - public void RebuildTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("MyCoreMLApp"); - - AssertCompiledModelExists ("SqueezeNet"); - - EnsureFilestampChange (); - - // Rebuild w/ no changes - BuildProject ("MyCoreMLApp", clean: false); - - AssertCompiledModelExists ("SqueezeNet"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/EmbeddedExtension.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/EmbeddedExtension.cs deleted file mode 100644 index da2d8c884d20..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/EmbeddedExtension.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class EmbeddedExtension : ProjectTest { - public EmbeddedExtension (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var proj = SetupProjectPaths ("NativeExtensionEmbedding/managed/ManagedContainer"); - MonoTouchProject = proj; - - var xcodeProjectFolder = Path.Combine (proj.ProjectPath, "..", "..", "native"); - string [] xcodeBuildArgs = new [] { "-configuration", "Debug", "-target", "NativeTodayExtension", "-sdk", Platform == "iPhoneSimulator" ? "iphonesimulator" : "iphoneos" }; - var env = new System.Collections.Generic.Dictionary { { "DEVELOPER_DIR", Configuration.XcodeLocation } }; - Assert.AreEqual (0, ExecutionHelper.Execute ("/usr/bin/xcodebuild", xcodeBuildArgs.Concat (new [] { "clean" }).ToList (), xcodeProjectFolder, Console.WriteLine, Console.Error.WriteLine)); - - var buildOutput = new StringBuilder (); - var buildCode = ExecutionHelper.Execute ("/usr/bin/xcodebuild", xcodeBuildArgs.Concat (new [] { "build" }).ToList (), xcodeProjectFolder, t => buildOutput.Append (t), t => buildOutput.Append (t)); - Assert.AreEqual (0, buildCode, $"Build Failed:{buildOutput}"); - - var properties = new Dictionary () - { - { "Platform", Platform }, - }; - - RunTarget (proj, "Clean", executionMode: ExecutionMode.MSBuild, properties: properties); - RunTarget (proj, "Build", executionMode: ExecutionMode.MSBuild, properties: properties); - - var expectedFilepath = Path.Combine (AppBundlePath, "PlugIns", "NativeTodayExtension.appex", "NativeTodayExtension"); - - Assert.That (File.Exists (expectedFilepath), $"NativeTodayExtension, file path '{expectedFilepath}' missing."); - - var expectedDirectories = new List (); - if (Platform == "iPhone") { - expectedDirectories.Add (Path.Combine (AppBundlePath, "_CodeSignature")); - expectedDirectories.Add (Path.Combine (AppBundlePath, "PlugIns", "NativeTodayExtension.appex", "_CodeSignature")); - } - - foreach (var dir in expectedDirectories) - Assert.That (dir, Does.Exist, "Directory should exist."); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Action.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Action.cs deleted file mode 100644 index 4081692ca3f2..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Action.cs +++ /dev/null @@ -1,23 +0,0 @@ -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class ActionTests : ExtensionTestBase { - public ActionTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildExtension ("MyTabbedApplication", "MyActionExtension"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/CustomKeyboard.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/CustomKeyboard.cs deleted file mode 100644 index b8aefdfff29b..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/CustomKeyboard.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using NUnit.Framework; -using System.Linq; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class CustomKeyboardTests : ExtensionTestBase { - public CustomKeyboardTests (string platform) : base (platform) - { - ExpectedAppFiles = new string [] { - "MainStoryboard_iPad.storyboardc", - "MainStoryboard_iPhone.storyboardc", - "default.metallib" - }; - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildExtension ("MyMetalGame", "MyKeyboardExtension"); - this.TestStoryboardC (AppBundlePath); - } - - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/DocumentPicker.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/DocumentPicker.cs deleted file mode 100644 index ec7fe8b0fe82..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/DocumentPicker.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class DocumentPickerTests : ExtensionTestBase { - - public DocumentPickerTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildExtension ("MyWebViewApp", "MyDocumentPickerExtension"); - this.TestStoryboardC (AppBundlePath); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs deleted file mode 100644 index bd861f7990cc..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/ExtensionTestBase.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.IO; -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; - -using Xamarin.Tests; - -namespace Xamarin.MacDev.Tasks { - public class ExtensionTestBase : TestBase { - public ExtensionTestBase () { } - - public ExtensionTestBase (string platform) - : base (platform) - { - } - - public ProjectPaths BuildExtension (string hostAppName, string extensionName, int expectedErrorCount = 0) - { - var mtouchPaths = SetupProjectPaths (hostAppName); - MonoTouchProject = mtouchPaths; - - string extensionPath = Path.Combine (AppBundlePath, "PlugIns", extensionName + ".appex"); - var proj = new ProjectPaths { - AppBundlePath = extensionPath, - }; - - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - Engine.ProjectCollection.SetGlobalProperty ("Configuration", Config); - - RunTarget (mtouchPaths, "Clean"); - Assert.IsFalse (Directory.Exists (AppBundlePath), "App bundle exists after cleanup: {0} ", AppBundlePath); - - RunTarget (mtouchPaths, "Build", expectedErrorCount: expectedErrorCount); - - if (expectedErrorCount > 0) - return proj; - - Assert.IsTrue (Directory.Exists (AppBundlePath), "App Bundle does not exist: {0} ", AppBundlePath); - - TestPList (AppBundlePath, new string [] { "CFBundleExecutable", "CFBundleVersion" }); - - Assert.IsTrue (Directory.Exists (extensionPath), "Appex directory does not exist: {0} ", extensionPath); - - TestPList (extensionPath, new string [] { "CFBundleExecutable", "CFBundleVersion" }); - - TestFilesExists (AppBundlePath, ExpectedAppFiles); - TestFilesDoNotExist (AppBundlePath, UnexpectedAppFiles); - - string [] coreFiles; - var basedirs = new List (); - basedirs.Add (AppBundlePath); - if (Platform == "iPhone") { - basedirs.Add (Path.Combine (AppBundlePath, ".monotouch-32")); - basedirs.Add (Path.Combine (AppBundlePath, "Frameworks", "Xamarin.Sdk.framework", "MonoBundle")); - basedirs.Add (Path.Combine (AppBundlePath, "Frameworks", "Xamarin.Sdk.framework", "MonoBundle", ".monotouch-32")); - } - coreFiles = GetCoreAppFiles (hostAppName + ".exe", hostAppName); - TestFilesExists (basedirs.ToArray (), coreFiles); - - return proj; - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/PhotoEditing.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/PhotoEditing.cs deleted file mode 100644 index ccc786e6ee02..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/PhotoEditing.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class PhotoEditingTests : ExtensionTestBase { - public PhotoEditingTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildExtension ("MySpriteKitGame", "MyPhotoEditingExtension"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Share.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Share.cs deleted file mode 100644 index fdfca6c7785b..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Share.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhoneSimulator")] - [TestFixture ("iPhone")] - public class ShareTests : ExtensionTestBase { - public ShareTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildExtension ("MyMasterDetailApp", "MyShareExtension"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Today.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Today.cs deleted file mode 100644 index 5afbd904c4e8..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/Extensions/Today.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class TodayTests : ExtensionTestBase { - public TodayTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildExtension ("MyOpenGLApp", "MyTodayExtension"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/IBToolLinking.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/IBToolLinking.cs deleted file mode 100644 index 4727abc86d9c..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/IBToolLinking.cs +++ /dev/null @@ -1,23 +0,0 @@ -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class IBToolLinking : ProjectTest { - public IBToolLinking (string platform) : base (platform) - { - } - - [Test] - public void BuildTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("MyIBToolLinkTest"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/LinkedAssets.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/LinkedAssets.cs deleted file mode 100644 index 774b130e79f0..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/LinkedAssets.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.IO; - -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class LinkedAssets : ProjectTest { - static readonly string [] IconNames = { "AppIcon60x60@2x.png" }; - - public LinkedAssets (string platform) : base (platform) - { - } - - [Test] - public void BuildTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("MyLinkedAssets"); - - foreach (var name in IconNames) { - var path = Path.Combine (AppBundlePath, name); - - Assert.That (path, Does.Exist, "The expected icon `{0}' does not exist.", name); - } - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferences.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferences.cs deleted file mode 100644 index f0b2ef260731..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferences.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class NativeReferencesTests : ProjectTest { - - public NativeReferencesTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var mtouchPaths = SetupProjectPaths ("MyTabbedApplication"); - - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - - var include = Path.Combine (Configuration.RootPath, "tests", "test-libraries", ".libs", "iossimulator", "XTest.framework"); - var metadata = new Dictionary { - { "IsCxx", "False" }, - { "Kind", "Framework" }, - }; - var proj = new MSBuildProject (mtouchPaths, this); - proj.AddItem ("NativeReference", include, metadata); - - MonoTouchProject = mtouchPaths; - - RunTarget (mtouchPaths, "Clean", 0); - RunTarget (mtouchPaths, "Build", 0); - - Assert.That (Directory.Exists (Path.Combine (AppBundlePath, "Frameworks", "XTest.framework")), "Frameworks/XTest.framework"); - Assert.That (File.Exists (Path.Combine (AppBundlePath, "Frameworks", "XTest.framework", "XTest")), "Frameworks/XTest.framework/XTest"); - } - - [Test] - public void WithIncrementalBuilds () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - if (Platform.Contains ("Simulator")) - return; // incremental builds on the simulator doesn't make much sense. - - var mtouchPaths = SetupProjectPaths ("MyiOSAppWithBinding"); - - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - - var properties = new Dictionary { - { "MtouchFastDev", "true" }, - { "MtouchExtraArgs", "-vvvv" }, - { "MtouchArch", "ARM64" }, // only use ARM64 to speed up the build. - { "MtouchLink", "Full" }, // also to speed up the build. - }; - - MonoTouchProject = mtouchPaths; - - RunTarget (mtouchPaths, "Clean", properties: properties); - RunTarget (mtouchPaths, "Build", properties: properties); - - Assert.That (Directory.Exists (Path.Combine (AppBundlePath, "Frameworks", "XTest.framework")), "Frameworks/XTest.framework"); - Assert.That (File.Exists (Path.Combine (AppBundlePath, "Frameworks", "XTest.framework", "XTest")), "Frameworks/XTest.framework/XTest"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs deleted file mode 100644 index a219801d83ce..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NUnit.Framework; -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class NativeReferencesNoEmbedding : ProjectTest { - - public NativeReferencesNoEmbedding (string platform) : base (platform) - { - } - - void BuildProjectNoEmbedding (ProjectPaths project, bool clean = true) - { - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - - if (clean) - RunTarget (project, "Clean"); - RunTarget (project, "Build"); - } - - string GetMessages () => string.Join ("\n", Engine.Logger.MessageEvents.Select (x => x.Message)); - - void ClearMessages () => Engine.Logger.MessageEvents.Clear (); - - // [TestCase (true)] MISSING_TEST - Tests are framework only - // [TestCase (false)] MISSING_TEST - Also, project reference only - public void LibrariesEmbeddedProperly (bool useProjectReference) - { - Assert.Fail (); - } - - [TestCase (true)] - // [TestCase (false)] MISSING_TEST - Framework only tests - public void ShouldNotUnnecessarilyRebuildBindingProject (bool framework) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - Assert.True (framework); - - var bindingLib = SetupProjectPaths ("MyiOSFrameworkBinding"); - - const string CreatePackageString = "Creating binding resource package"; - - // First build should create a package - BuildProjectNoEmbedding (bindingLib); - Assert.True (GetMessages ().Contains (CreatePackageString), "First build did not create package?"); - ClearMessages (); - - // No change build should not - BuildProjectNoEmbedding (bindingLib, clean: false); - Assert.False (GetMessages ().Contains (CreatePackageString), "Rebuild build did create package?"); - ClearMessages (); - - // Touching the binding project should - Touch (bindingLib.ProjectCSProjPath); - BuildProjectNoEmbedding (bindingLib, clean: false); - Assert.True (GetMessages ().Contains (CreatePackageString), "Binding project build did not create package?"); - ClearMessages (); - - // Touching the binding file should - Touch (Path.Combine (Configuration.RootPath, "tests", "bindings-framework-test", "ApiDefinition.cs")); - BuildProjectNoEmbedding (bindingLib, clean: false); - Assert.True (GetMessages ().Contains (CreatePackageString), "Binding file build did not create package?"); - ClearMessages (); - - // No change build should not - BuildProjectNoEmbedding (bindingLib, clean: false); - Assert.False (GetMessages ().Contains (CreatePackageString), "Second rebuild build did create package?"); - ClearMessages (); - - // Touching native library should - Touch (Path.Combine (Configuration.RootPath, "tests", "test-libraries", ".libs", "iossimulator", "XTest.framework", "XTest")); - BuildProjectNoEmbedding (bindingLib, clean: false); - Assert.True (GetMessages ().Contains (CreatePackageString), "Binding build did not create package?"); - } - - [TestCase (true)] - // [TestCase (false)] MISSING_TEST - Project reference only - public void ShouldNotUnnecessarilyRebuildFinalProject (bool useProjectReference) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - Assert.True (useProjectReference); - - var appProject = SetupProjectPaths ("MyiOSAppWithBinding"); - - // Look for partial match of the '/path/to/mtouch @responsefile' command - string BuildString = "mtouch @"; - - // First build should create run mtouch - BuildProjectNoEmbedding (appProject); - Assert.That (GetMessages (), Does.Contain (BuildString), "First build did not run mtouch?"); - ClearMessages (); - - // But not a rebuild - BuildProjectNoEmbedding (appProject, clean: false); - Assert.That (GetMessages (), Does.Not.Contain (BuildString), "Rebuild build did run mtouch?"); - ClearMessages (); - - if (!useProjectReference) { - Assert.Fail (); // TODO - Checked in projects are project reference only... - } else { - var libProject = SetupProjectPaths ("MyiOSFrameworkBinding"); - - Touch (libProject.ProjectCSProjPath); - BuildProjectNoEmbedding (appProject, clean: false); - Assert.True (GetMessages ().Contains (BuildString), "Binding binary build did not run mtouch?"); - } - } - - // [TestCase (true)] - MISSING_TEST - Requires special "chain" project that is not checked in - // [TestCase (false)] - MISSING_TEST - Requires special "chain" project that is not checked in - public void MultipleDependencyChain (bool useProjectReference) - { - Assert.Fail (); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectReference.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectReference.cs deleted file mode 100644 index c21fc0dc3eb8..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectReference.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class ProjectReferenceTests : ProjectTest { - - public ProjectReferenceTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - NugetRestore (Path.Combine (Configuration.TestProjectsDirectory, "MyAppWithPackageReference", "MyAppWithPackageReference.csproj")); - NugetRestore (Path.Combine (Configuration.TestProjectsDirectory, "MyExtensionWithPackageReference", "MyExtensionWithPackageReference.csproj")); - - // Can't use the in-process MSBuild engine, because it complains that the project file is invalid (the attribute 'Version' in the element '' is unrecognized) - var rv = ExecutionHelper.Execute ("Legacy projects not supported anymore", new [] { "--", Path.Combine (Configuration.TestProjectsDirectory, "MyAppWithPackageReference", "MyAppWithPackageReference.csproj"), $"/p:Platform={Platform}", "/p:Configuration=Debug" }, out var output); - if (rv != 0) { - Console.WriteLine ("Build failed:"); - Console.WriteLine (output); - Assert.AreEqual (0, rv, "Build failed"); - } - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs deleted file mode 100644 index eb4b7c7b9ae2..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NUnit.Framework; - -using Xamarin.Tests; - -namespace Xamarin.MacDev.Tasks { - public class ProjectTest : TestBase { - public ProjectTest (string platform) - : base (platform) - { - } - - public ProjectTest (string platform, string config) - : base (platform, config) - { - } - - public ProjectPaths BuildProject (string appName, int expectedErrorCount = 0, bool clean = true, bool nuget_restore = false, bool is_library = false, Dictionary properties = null) - { - var mtouchPaths = SetupProjectPaths (appName); - var csproj = mtouchPaths.ProjectCSProjPath; - - MonoTouchProject = mtouchPaths; - Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform); - Engine.ProjectCollection.SetGlobalProperty ("Configuration", Config); - - if (nuget_restore) - NugetRestore (csproj); - - if (clean) { - RunTarget (mtouchPaths, "Clean", Mode, properties: properties); - Assert.IsFalse (Directory.Exists (AppBundlePath), "App bundle exists after cleanup: {0} ", AppBundlePath); - Assert.IsFalse (Directory.Exists (AppBundlePath + ".dSYM"), "App bundle .dSYM exists after cleanup: {0} ", AppBundlePath + ".dSYM"); - Assert.IsFalse (Directory.Exists (AppBundlePath + ".mSYM"), "App bundle .mSYM exists after cleanup: {0} ", AppBundlePath + ".mSYM"); - - var baseDir = Path.GetDirectoryName (csproj); - var objDir = Path.Combine (baseDir, "obj", Platform, Config); - var binDir = Path.Combine (baseDir, "bin", Platform, Config); - - if (Directory.Exists (objDir)) { - var paths = Directory.EnumerateFiles (objDir, "*.*", SearchOption.AllDirectories) - .Where (v => !v.EndsWith (".FileListAbsolute.txt", StringComparison.Ordinal)) - .Where (v => !v.EndsWith (".assets.cache", StringComparison.Ordinal)); - Assert.IsEmpty (paths, "Files not cleaned:\n\t{0}", string.Join ("\n\t", paths)); - } - - if (Directory.Exists (binDir)) { - var paths = Directory.EnumerateFiles (binDir, "*.*", SearchOption.AllDirectories); - Assert.IsEmpty (paths, "Files not cleaned:\n\t{0}", string.Join ("\n\t", paths)); - } - } - - RunTarget (mtouchPaths, "Build", Mode, expectedErrorCount, properties: properties); - - if (expectedErrorCount > 0 || is_library) - return mtouchPaths; - - Assert.IsTrue (Directory.Exists (AppBundlePath), "App Bundle does not exist: {0} ", AppBundlePath); - - TestFilesExists (AppBundlePath, ExpectedAppFiles); - TestFilesDoNotExist (AppBundlePath, UnexpectedAppFiles); - - if (Mode != ExecutionMode.DotNet) { - var coreFiles = GetCoreAppFiles (appName.Replace (" ", "") + ".exe", appName.Replace (" ", "")); - var baseDirs = new string [] { - Path.Combine (AppBundlePath, ".monotouch-32"), - Path.Combine (AppBundlePath, ".monotouch-64"), - AppBundlePath, - Path.Combine (AppBundlePath, "Frameworks", "Xamarin.Sdk.framework", "MonoBundle", ".monotouch-32"), - Path.Combine (AppBundlePath, "Frameworks", "Xamarin.Sdk.framework", "MonoBundle", ".monotouch-64"), - Path.Combine (AppBundlePath, "Frameworks", "Xamarin.Sdk.framework", "MonoBundle"), - }; - TestFilesExists (baseDirs, coreFiles); - } - - if (Platform == "iPhone") { - var dSYMInfoPlist = Path.Combine (AppBundlePath + ".dSYM", "Contents", "Info.plist"); - var nativeExecutable = Path.Combine (AppBundlePath, appName); - - Assert.That (dSYMInfoPlist, Does.Exist, "dSYM Info.plist file does not exist"); - Assert.That (File.GetLastWriteTimeUtc (dSYMInfoPlist), Is.GreaterThanOrEqualTo (File.GetLastWriteTimeUtc (nativeExecutable)), $"dSYM Info.plist ({dSYMInfoPlist}) should be newer than the native executable ({nativeExecutable})"); - } - - return mtouchPaths; - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithFrameworks.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithFrameworks.cs deleted file mode 100644 index 63a93394c024..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithFrameworks.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.IO; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class ProjectWithFrameworksTests : ExtensionTestBase { - public ProjectWithFrameworksTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildExtension ("MyMasterDetailApp", "MyShareExtension"); - - // Verify that Mono.frameworks is in the app - Assert.That (Directory.Exists (Path.Combine (AppBundlePath, "Frameworks")), "Frameworks exists"); - Assert.That (Directory.Exists (Path.Combine (AppBundlePath, "Frameworks", "Mono.framework")), "Mono.framework exists"); - Assert.That (File.Exists (Path.Combine (AppBundlePath, "Frameworks", "Mono.framework", "Mono")), "Mono.framework/Mono exists"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithSpaces.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithSpaces.cs deleted file mode 100644 index 1deb58f4d0f3..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectWithSpaces.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Linq; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class ProjectWithSpacesTests : ProjectTest { - public ProjectWithSpacesTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildProject ("My Spaced App", clean: false); - - // Message of the form: - // Property reassignment: $(AssemblySearchPaths)="..." (previous value: "...") at Xamarin.iOS.Common.props (106,3) - var assemblySearchPaths = Engine.Logger.MessageEvents.FirstOrDefault (m => m.Message.Contains ("Property reassignment: $(AssemblySearchPaths)=\"")); - Assert.IsNotNull (assemblySearchPaths, "$(AssemblySearchPaths) should be modified"); - var split = assemblySearchPaths.Message.Split ('"'); - Assert.GreaterOrEqual (split.Length, 1, "Unexpected string contents"); - Assert.IsFalse (split [1].Contains ("{GAC}"), "$(AssemblySearchPaths) should not contain {GAC}"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ReleaseBuild.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ReleaseBuild.cs deleted file mode 100644 index d896b198fe42..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ReleaseBuild.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -using NUnit.Framework; -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - public class ReleaseBuild : ProjectTest { - public ReleaseBuild (string platform) - : base (platform, "Release") - { - } - - [Test] - public void BuildTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("MyReleaseBuild"); - - var args = new List { "-r", "UIWebView", AppBundlePath }; - ExecutionHelper.Execute ("grep", args, out var output); - Assert.That (output.ToString (), Is.Empty, "UIWebView"); - } - - [Test] - public void RebuildTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var csproj = BuildProject ("MyReleaseBuild"); - - var dsymDir = Path.GetFullPath (Path.Combine (AppBundlePath, "..", Path.GetFileName (AppBundlePath) + ".dSYM")); - - var timestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - var dsymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - - EnsureFilestampChange (); - - // Rebuild w/ no changes - BuildProject ("MyReleaseBuild", clean: false); - - var newTimestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - var newDSymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - - foreach (var file in timestamps.Keys) - Assert.AreEqual (timestamps [file], newTimestamps [file], "#1: " + file); - - foreach (var file in dsymTimestamps.Keys) - Assert.AreEqual (dsymTimestamps [file], newDSymTimestamps [file], "#2: " + file); - - EnsureFilestampChange (); - - // Rebuild after changing MtouchUseLlvm - var proj = new MSBuildProject (csproj, this); - proj.SetProperty ("MtouchUseLlvm", "true"); - BuildProject ("MyReleaseBuild", clean: false); - - newTimestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - newDSymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - - foreach (var file in timestamps.Keys) { - var fileName = Path.GetFileName (file); - - var isModificationExpected = false; - - if (fileName.EndsWith (".aotdata.armv7", StringComparison.Ordinal) || fileName.EndsWith (".aotdata.arm64", StringComparison.Ordinal)) { - // aotdata files should be modified - isModificationExpected = true; - } else if (fileName == "MyReleaseBuild") { - // the executable must of course be modified - isModificationExpected = true; - } else if (fileName == "CodeResources") { - // the signature has of course changed too - isModificationExpected = true; - } else if (fileName.EndsWith (".dll", StringComparison.Ordinal) || fileName.EndsWith (".exe", StringComparison.Ordinal)) { - // I'm not sure if assemblies have to be modified, but they currently are, so mark them as such to make the test pass. - isModificationExpected = true; - } - - if (isModificationExpected) - Assert.AreNotEqual (timestamps [file], newTimestamps [file], "#3: " + file); - else - Assert.AreEqual (timestamps [file], newTimestamps [file], "#3: " + file); - } - - foreach (var file in dsymTimestamps.Keys) - Assert.AreNotEqual (dsymTimestamps [file], newDSymTimestamps [file], "#4: " + file); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ResponseFileArguments.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ResponseFileArguments.cs deleted file mode 100644 index 12db23844a36..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ResponseFileArguments.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - public class ResponseFileArguments : ProjectTest { - public ResponseFileArguments () : base ("iPhoneSimulator") - { - } - - [Test] - public void ProjectWithExtraArgment_CorrectlyOverridesLinkingParam () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("AppWithExtraArgumentThatOverrides"); - Assert.True (Engine.Logger.MessageEvents.Any (x => x.Message.Contains ("using mode 'SDKOnly'"))); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/SystemMemoryReference.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/SystemMemoryReference.cs deleted file mode 100644 index 0ca5a35dbd0e..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/SystemMemoryReference.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class SystemMemoryReferenceTests : ProjectTest { - - public SystemMemoryReferenceTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - this.BuildProject ("SystemMemoryReference", clean: false); - - Assert.IsTrue (File.Exists (Path.Combine (AppBundlePath, "SystemMemoryReference")), "App bundle not created properly"); - Assert.IsFalse (File.Exists (Path.Combine (AppBundlePath, "System.Memory.dll")), "System.Memory.dll was incorrectly copied from NuGet"); - } - - [Test] - public void NetStandard2_0ReferenceFromLibraryAndDirectNuGetReference () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("SystemMemoryLibrary", clean: false, nuget_restore: true, is_library: true); - BuildProject ("SystemMemoryFromNetStandard2_0", clean: false, nuget_restore: true); - - var primaryReferenceIndex = Engine.MessageEvents.FindIndex ((v) => v.Message.TrimStart ().StartsWith ("Primary reference \"System.Memory, Version") && v.ProjectFile.Contains ("SystemMemoryFromNetStandard2_0.csproj")); - Assert.That (primaryReferenceIndex, Is.GreaterThanOrEqualTo (0), "Failure to find primary reference result in build log"); - var resolvedFilePath = Engine.MessageEvents [primaryReferenceIndex + 1]; - - Assert.That (resolvedFilePath.Message, Does.Contain ("Resolved file path is "), "ResolvedFilePath 1"); - Assert.That (resolvedFilePath.Message, Does.Contain ("/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades/System.Memory.dll"), "ResolvedFilePath 2"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVApp.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVApp.cs deleted file mode 100644 index b954a18c6aca..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVApp.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class TVAppTests : ExtensionTestBase { - public TVAppTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.TVOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildExtension ("MyTVApp", "MyTVServicesExtension"); - } - - public override string TargetFrameworkIdentifier { - get { - return "Xamarin.TVOS"; - } - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVMetalGameTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVMetalGameTests.cs deleted file mode 100644 index 0659faf3df05..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/TVOS/TVMetalGameTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class TVMetalGameTests : ProjectTest { - public TVMetalGameTests (string platform) : base (platform) - { - } - - [Test] - public void BasicTest () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.TVOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildProject ("MyTVMetalGame"); - } - - public override string TargetFrameworkIdentifier { - get { - return "Xamarin.TVOS"; - } - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/XamarinForms.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/XamarinForms.cs deleted file mode 100644 index 2fb149ecba0e..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/XamarinForms.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.IO; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture ("iPhone")] - [TestFixture ("iPhoneSimulator")] - public class XamarinForms : ProjectTest { - public XamarinForms (string platform) : base (platform) - { - } - - [Test] - public void IncrementalBuilds () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var testdir = GetTestDirectory (); - NugetRestore (Path.Combine (testdir, "MyXamarinFormsApp", "MyXamarinFormsApp.csproj")); - NugetRestore (Path.Combine (testdir, "MyXamarinFormsApp", "MyXamarinFormsAppNS", "MyXamarinFormsAppNS.csproj")); - - // First build - BuildProject ("MyXamarinFormsApp"); - Assert.IsFalse (IsTargetSkipped ("_CompileToNative"), "_CompileToNative should *not* be skipped on first build."); - - // Build with no changes - BuildProject ("MyXamarinFormsApp", clean: false); - Assert.IsTrue (IsTargetSkipped ("_CompileToNative"), "_CompileToNative should be skipped on a build with no changes."); - - // Build with XAML change - Touch (Path.Combine (testdir, "MyXamarinFormsApp", "MyXamarinFormsAppNS", "App.xaml")); - BuildProject ("MyXamarinFormsApp", clean: false); - - Assert.IsFalse (IsTargetSkipped ("_CompileToNative"), "_CompileToNative should *not* be skipped on a build with a XAML change."); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/RoslynSmokeTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/RoslynSmokeTests.cs deleted file mode 100644 index fd9c00723461..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/RoslynSmokeTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.IO; -using System.Text; -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MMP.Tests { - [TestFixture] - public partial class MMPTests { - public string RoslynTestProjectRoot => Path.Combine (Configuration.TestProjectsDirectory, "RoslynTestApp"); - - [Test] - public void XMModernRoslynProject_ShouldBuildAndRunWithMSBuild () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - string projectPath = Path.Combine (RoslynTestProjectRoot, "Modern/RoslynTestApp.sln"); - - TI.CleanUnifiedProject (projectPath); - TI.BuildProject (projectPath); - TI.RunAndAssert (Path.Combine (RoslynTestProjectRoot, "Modern/bin/Debug/RoslynTestApp.app/Contents/MacOS/RoslynTestApp"), Array.Empty (), "Run"); - } - - [Test] - public void XMFullRoslynProject_ShouldBuildAndRunWithMSBuild () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - string projectPath = Path.Combine (RoslynTestProjectRoot, "Full/RoslynTestApp.sln"); - - TI.CleanUnifiedProject (projectPath); - TI.BuildProject (projectPath); - TI.RunAndAssert (Path.Combine (RoslynTestProjectRoot, "Full/bin/Debug/RoslynTestApp.app/Contents/MacOS/RoslynTestApp"), Array.Empty (), "Run"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/RuntimeTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/RuntimeTests.cs deleted file mode 100644 index daf5aed8eace..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/RuntimeTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.IO; -using System.Text; - -using NUnit.Framework; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MMP.Tests { - [TestFixture] - public class RuntimeTests { - [Test] - public void AssemblyRegistration () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var projectName = "AssemblyRegistration"; - var projectPath = Path.Combine (Configuration.TestProjectsDirectory, projectName, $"{projectName}.csproj"); - - TI.CleanUnifiedProject (projectPath); - TI.BuildProject (projectPath); - TI.RunAndAssert (Path.Combine (Path.GetDirectoryName (projectPath), $"bin/Debug/{projectName}.app/Contents/MacOS/{projectName}"), Array.Empty (), "Run"); - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/CollectAppManifestsTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/CollectAppManifestsTests.cs index 47aa8e7ac723..300230c060e4 100644 --- a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/CollectAppManifestsTests.cs +++ b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/CollectAppManifestsTests.cs @@ -16,7 +16,6 @@ public class CollectAppManifestsTests { public void PartialAppManifest () { Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertDotNetAvailable (); var csproj = $@" @@ -65,7 +64,7 @@ public void PartialAppManifest () var properties = new Dictionary { { "_CreateAppManifest", "true" }, }; - var rv = engine.RunTarget (ApplePlatform.MacOSX, ExecutionMode.DotNet, csprojPath, target: "_WriteAppManifest", properties: properties); + var rv = engine.RunTarget (ApplePlatform.MacOSX, csprojPath, target: "_WriteAppManifest", properties: properties); Assert.AreEqual (0, rv.ExitCode, "Exit code"); var appManifestPath = Path.Combine (tmpdir, "bin", "Debug", Configuration.DotNetTfm + "-macos", "osx-x64", "PartialAppManifest.app", "Contents", "Info.plist"); diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/DetectSigningIdentityTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/DetectSigningIdentityTests.cs index d52a2d86113b..0fca7ac2a9d6 100644 --- a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/DetectSigningIdentityTests.cs +++ b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/DetectSigningIdentityTests.cs @@ -19,7 +19,6 @@ public class DetectSigningIdentityTests { public void BundleIdentifierInPartialAppManifest () { Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.MacOSX); - Configuration.AssertDotNetAvailable (); // https://github.com/dotnet/macios/issues/12051 var csproj = $@" @@ -59,7 +58,7 @@ public void BundleIdentifierInPartialAppManifest () var properties = new Dictionary { { "_CanOutputAppBundle", "true" }, }; - var rv = engine.RunTarget (ApplePlatform.MacOSX, ExecutionMode.DotNet, csprojPath, target: "_DetectSigningIdentity", properties: properties); + var rv = engine.RunTarget (ApplePlatform.MacOSX, csprojPath, target: "_DetectSigningIdentity", properties: properties); Assert.AreEqual (0, rv.ExitCode, "Exit code"); // Find the BundleIdentifier parameter to the DetectSigningIdentity task. diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/TargetTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/TargetTests.cs index 7666ad04743c..5d7261bcd7e3 100644 --- a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/TargetTests.cs +++ b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/TargetTests.cs @@ -17,216 +17,12 @@ public TargetTests () { } - string [] ExpectedExecutableBundleResources { - get { - var files = new [] { - Path.Combine ("Folder", "BundleResource.txt"), - Path.Combine ("Folder", "Content.txt"), - Path.Combine ("Folder", "LinkedBundleResource.txt"), - Path.Combine ("Folder", "LinkedContent.txt"), - Path.Combine ("MainStoryboard.storyboardc", "1-view-2.nib"), - Path.Combine ("MainStoryboard.storyboardc", "Info.plist"), - Path.Combine ("MainStoryboard.storyboardc", "UIViewController-1.nib"), - Path.Combine ("Archer", "Archer_Attack.atlasc", "Archer_Attack.1.png"), - Path.Combine ("Archer", "Archer_Attack.atlasc", "Archer_Attack.plist"), - Path.Combine ("en.lproj", "TranslatedView.nib"), - "FolderView.nib", - "iPhoneView.nib", - "image.png", - "AppIcons60x60@2x.png", - "LaunchImage-568h@2x.png", - "LaunchImage.png", - "LaunchImage@2x.png", - "Assets.car", - }; - return files.Select (s => Path.Combine (AppBundlePath, s)).ToArray (); - } - } - - string [] ExpectedLibraryBundleResources { - get { - var files = new [] { - Path.Combine ("LibrarySecondStoryboard.storyboardc", "43-view-49.nib"), - Path.Combine ("LibrarySecondStoryboard.storyboardc", "45-view-53.nib"), - Path.Combine ("LibrarySecondStoryboard.storyboardc", "Info.plist"), - Path.Combine ("LibrarySecondStoryboard.storyboardc", "UITabBarController-41.nib"), - Path.Combine ("LibraryStoryboard.storyboardc", "1-view-2.nib"), - Path.Combine ("LibraryStoryboard.storyboardc", "Info.plist"), - Path.Combine ("LibraryStoryboard.storyboardc", "UIViewController-1.nib"), - Path.Combine ("MyLibraryFolder", "LibraryBundleResource.txt"), - Path.Combine ("MyLibraryFolder", "LibraryContent.txt"), - Path.Combine ("MyLibraryFolder", "LibraryLinkedBundleResource.txt"), - Path.Combine ("MyLibraryFolder", "LibraryLinkedContent.txt"), - }; - return files.Select (s => Path.Combine (AppBundlePath, s)).ToArray (); - } - } - - string [] ExpectedExecutableFiles { - get { - var files = new [] { - "MonoTouchDebugConfiguration.txt", - "Info.plist", - Path.Combine ("Settings.bundle", "Root.plist"), - "MyLibrary.dll", - "MyLibrary.pdb", - "MySingleView", - "MySingleView.exe", - "MySingleView.pdb", - "System.Core.dll", - "System.Core.pdb", - "System.Xml.dll", - "System.Xml.pdb", - "System.dll", - "System.pdb", - "Xamarin.iOS.dll", - "Xamarin.iOS.pdb", - "mscorlib.dll", - "mscorlib.pdb", - "runtime-options.plist", - }; - - var expected = new List (); - expected.AddRange (files.Select (s => Path.Combine (AppBundlePath, s))); - expected.AddRange (ExpectedExecutableBundleResources); - expected.AddRange (ExpectedLibraryBundleResources); - - return expected.ToArray (); - } - } - - static string [] ExpectedLibraryEmbeddedResources { - get { - return new [] { - "MyLibrary.MyLibraryFolder.LibraryLinkedEmbeddedResource.txt", - "MyLibrary.MyLibraryFolder.LibraryEmbeddedResource.txt", - "__monotouch_content_MyLibraryFolder_sLibraryLinkedBundleResource.txt", - "__monotouch_content_MyLibraryFolder_sLibraryBundleResource.txt", - "__monotouch_content_MyLibraryFolder_sLibraryLinkedContent.txt", - "__monotouch_content_MyLibraryFolder_sLibraryContent.txt", - "__monotouch_content_LibraryStoryboard.storyboardc_s1-view-2.nib", - "__monotouch_content_LibraryStoryboard.storyboardc_sInfo.plist", - "__monotouch_content_LibraryStoryboard.storyboardc_sUIViewController-1.nib", - "__monotouch_content_LibrarySecondStoryboard.storyboardc_s43-view-49.nib", - "__monotouch_content_LibrarySecondStoryboard.storyboardc_s45-view-53.nib", - "__monotouch_content_LibrarySecondStoryboard.storyboardc_sInfo.plist", - "__monotouch_content_LibrarySecondStoryboard.storyboardc_sUITabBarController-41.nib" - }; - } - } - - static void BundleResourceExists (string path) - { - if (Path.GetExtension (path) == ".nib") { - if (Directory.Exists (path)) { - // Note: this suggests that things were built with the iOS 8 SDK... - var objects8Nib = Path.Combine (path, "objects-8.0+.nib"); - var objects13Nib = Path.Combine (path, "objects-13.0+.nib"); - var objectsNib = Path.Combine (path, "objects.nib"); - var runtimeNib = Path.Combine (path, "runtime.nib"); - - Assert.That (File.Exists (runtimeNib), $"File exists: {runtimeNib}"); - Assert.That (File.Exists (objectsNib) || File.Exists (objects8Nib) || File.Exists (objects13Nib), $"File exists: {objectsNib} || {objects8Nib} || {objects13Nib}"); - return; - } - } - - Assert.That (path, Does.Exist, $"Existence of {path}"); - } - - [Test] - public void GetReferencedAssemblies_Executable () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (MonoTouchProject, TargetName.ResolveReferences); - var references = MonoTouchProjectInstance.GetItems ("ReferencePath").ToArray (); - var expected_references = new string [] { - "MyLibrary.dll", - "System.dll", - "System.Xml.dll", - "System.Core.dll", - "mscorlib.dll", - "Xamarin.iOS.dll", - "System.Drawing.Common.dll", - }; - Array.Sort (expected_references); - - var actual_references = references.Select ((v) => Path.GetFileName (v.EvaluatedInclude)).OrderBy ((v) => v); - CollectionAssert.AreEquivalent (expected_references, actual_references, "References"); - } - - [Test] - public void GetReferencedAssemblies_Library () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (LibraryProject, TargetName.ResolveReferences); - var references = LibraryProjectInstance.GetItems ("ReferencePath").ToArray (); - var expected_references = new string [] { - "System.dll", - "System.Xml.dll", - "System.Core.dll", - "mscorlib.dll", - "Xamarin.iOS.dll", - "System.Drawing.Common.dll", - }; - Array.Sort (expected_references); - - var actual_references = references.Select ((v) => Path.GetFileName (v.EvaluatedInclude)).OrderBy ((v) => v); - CollectionAssert.AreEquivalent (expected_references, actual_references, "References"); - } - - [Test] - public void BuildExecutable () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var expectedFiles = ExpectedExecutableFiles; - - RunTarget (MonoTouchProject, TargetName.Build); - - Assert.IsTrue (Directory.Exists (AppBundlePath), "#1"); - - var bundleResources = Directory.GetFileSystemEntries (AppBundlePath, "*", SearchOption.AllDirectories); - var inexistentResource = expectedFiles.Except (expectedFiles).ToArray (); - - Assert.That (inexistentResource, Is.Empty, "No missing resources"); - - foreach (var file in expectedFiles) - BundleResourceExists (file); - - // Verify that we have not bundled BundleResource or Content items as embedded resources - var assemblyDef = AssemblyDefinition.ReadAssembly (Path.Combine (AppBundlePath, "MySingleView.exe")); - Assert.AreEqual (2, assemblyDef.MainModule.Resources.OfType ().Count (), "#3"); - - var plist = PDictionary.FromFile (Path.Combine (AppBundlePath, "Info.plist")); - Assert.IsTrue (plist.ContainsKey ("CFBundleExecutable")); - Assert.IsTrue (plist.ContainsKey ("CFBundleVersion")); - Assert.IsNotEmpty (((PString) plist ["CFBundleExecutable"]).Value); - Assert.IsNotEmpty (((PString) plist ["CFBundleVersion"]).Value); - } - - [Test] - public void CopyContentToBundle () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (MonoTouchProject, TargetName.CopyResourcesToBundle); - - foreach (var v in ExpectedExecutableBundleResources) - Assert.That (v, Does.Exist, string.Format ("{0} was not copied to the bundle", Path.GetFullPath (v))); - } - [Test] public void CleanExecutable () { Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET + Configuration.AssertLegacyXamarinAvailable (); + // .NET: we don't have a test that verifies that the Clean target works as expected, this needs to be added before we can remove this test. RunTarget (MonoTouchProject, TargetName.Clean); Assert.IsFalse (Directory.Exists (MonoTouchProjectBinPath), "#1a"); @@ -243,7 +39,8 @@ public void CleanExecutable () public void CleanLibrary () { Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET + Configuration.AssertLegacyXamarinAvailable (); + // .NET: we don't have a test that verifies that the Clean target works as expected, this needs to be added before we can remove this test. RunTarget (LibraryProject, TargetName.Clean); Assert.IsFalse (Directory.Exists (LibraryProjectBinPath), "#1a"); @@ -255,16 +52,6 @@ public void CleanLibrary () Assert.IsFalse (Directory.Exists (LibraryProjectObjPath), "#2b"); } - [Test] - public void CompileInterfaceDefinitions_Library () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (LibraryProject, TargetName.CompileInterfaceDefinitions); - Assert.IsNotEmpty (Directory.GetFiles (LibraryProjectObjPath, "*.*", SearchOption.AllDirectories), "#1"); - } - [Test] public void OptimizePngs_DefaultValue () { @@ -274,7 +61,8 @@ public void OptimizePngs_DefaultValue () [Test] public void OptimizePngs_True () { - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET + Configuration.AssertLegacyXamarinAvailable (); + // .NET: we're currently not enabling png optimization (https://github.com/dotnet/macios/issues/20129), we need to enable that, and add a corresponding test, before we can remove this test. MonoTouchProjectInstance.SetProperty ("OptimizePNGs", "True"); OptimizePngs_Core (true); } @@ -282,7 +70,8 @@ public void OptimizePngs_True () [Test] public void OptimizePngs_False () { - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET + Configuration.AssertLegacyXamarinAvailable (); + // .NET: we're currently not enabling png optimization (https://github.com/dotnet/macios/issues/20129), we need to enable that, and add a corresponding test, before we can remove this test. MonoTouchProjectInstance.SetProperty ("OptimizePNGs", "False"); OptimizePngs_Core (false); } @@ -290,7 +79,8 @@ public void OptimizePngs_False () void OptimizePngs_Core (bool shouldBeDifferent) { Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET + Configuration.AssertLegacyXamarinAvailable (); + // .NET: we're currently not enabling png optimization (https://github.com/dotnet/macios/issues/20129), we need to enable that, and add a corresponding test, before we can remove this test. var originalFile = Path.Combine (MonoTouchProjectPath, "Resources", "image.png"); var optimisedFile = Path.Combine (AppBundlePath, "image.png"); @@ -303,407 +93,5 @@ void OptimizePngs_Core (bool shouldBeDifferent) else CollectionAssert.AreEqual (File.ReadAllBytes (originalFile), File.ReadAllBytes (optimisedFile), "#2b"); } - - [Test] - public void RebuildExecutable_NoModifications () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - // Put a thread.sleep so that the initial build happens a noticable amount of time after we copy - // all the input files into the temporary directory. This means that any timestamps modified as - // part of the original build will definitely be newer than the timestamps written during the - // execution of the test fixture 'setup' method. - EnsureFilestampChange (); - RunTarget (MonoTouchProject, TargetName.Build); - var timestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - - EnsureFilestampChange (); - RunTarget (MonoTouchProject, TargetName.Build); - var newTimestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file)); - - foreach (var file in timestamps.Keys) - Assert.AreEqual (timestamps [file], newTimestamps [file], "#1: " + file); - } - - [Test] - public void RebuildExecutable_TouchLibraryDll () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (MonoTouchProject, TargetName.Build); - var timestamps = ExpectedExecutableFiles.ToDictionary (file => file, file => GetLastModified (file)); - - Touch (Path.Combine (LibraryProjectObjPath, "MyLibrary.dll")); - RunTarget (MonoTouchProject, TargetName.Build); - var newTimestamps = ExpectedExecutableFiles.ToDictionary (file => file, file => GetLastModified (file)); - - // At least some files should be modified now - Assert.IsTrue (timestamps.Keys.Any (key => timestamps [key] != newTimestamps [key]), "#1"); - } - - [Test] - public void RebuildLibrary_NoModifications () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var libraryPath = Path.Combine (LibraryProjectBinPath, "MyLibrary.dll"); - - RunTarget (LibraryProject, TargetName.Build); - var timestamp = GetLastModified (libraryPath); - - EnsureFilestampChange (); - RunTarget (LibraryProject, TargetName.Build); - Assert.AreEqual (timestamp, GetLastModified (libraryPath)); - } - - [Test] - public void RebuildLibrary_TouchBundleResource () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var libraryPath = Path.Combine (LibraryProjectBinPath, "MyLibrary.dll"); - - RunTarget (LibraryProject, TargetName.Build); - var timestamp = GetLastModified (libraryPath); - - Touch (Path.Combine (LibraryProjectPath, "MyLibraryFolder", "LibraryBundleResource.txt")); - RunTarget (LibraryProject, TargetName.Build); - Assert.AreNotEqual (timestamp, GetLastModified (libraryPath)); - } - - [Test] - public void RebuildLibrary_TouchEmbeddedResource () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var libraryPath = Path.Combine (LibraryProjectBinPath, "MyLibrary.dll"); - - RunTarget (LibraryProject, TargetName.Build); - var timestamp = GetLastModified (libraryPath); - - Touch (Path.Combine (LibraryProjectPath, "MyLibraryFolder", "LibraryEmbeddedResource.txt")); - RunTarget (LibraryProject, TargetName.Build); - Assert.AreNotEqual (timestamp, GetLastModified (libraryPath)); - } - - [Test] - public void RebuildLibrary_TouchStoryboard () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var libraryPath = Path.Combine (LibraryProjectBinPath, "MyLibrary.dll"); - - RunTarget (LibraryProject, TargetName.Build); - var timestamp = GetLastModified (libraryPath); - - Touch (Path.Combine (LibraryProjectPath, "LibraryStoryboard.storyboard")); - RunTarget (LibraryProject, TargetName.Build); - Assert.AreNotEqual (timestamp, GetLastModified (libraryPath)); - } - - [Test] - public void BuildLibrary () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - BuildLibraryCore (ExpectedLibraryEmbeddedResources); - } - - [Test] - public void BuildLibrary_NoInterfaceDefinitions () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - LibraryProjectInstance.RemoveItems ("InterfaceDefinition"); - - BuildLibraryCore (ExpectedLibraryEmbeddedResources.Where (s => !s.Contains ("storyboardc")).ToArray ()); - } - - void BuildLibraryCore (string [] expectedResources) - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var library = Path.Combine (LibraryProjectBinPath, "MyLibrary.dll"); - RunTarget (LibraryProject, TargetName.Build); - - Assert.IsTrue (string.IsNullOrEmpty (LibraryProjectInstance.GetPropertyValue ("AppBundleDir")), "#1"); - var entries = Directory.GetFileSystemEntries (LibraryProjectBinPath); - Assert.AreEqual (2, entries.Length, "#1"); - Assert.IsTrue (File.Exists (library), "#2"); - Assert.IsTrue (File.Exists (Path.ChangeExtension (library, ".pdb")), "#3"); - - var assemblyDef = AssemblyDefinition.ReadAssembly (library); - var actualResources = assemblyDef.MainModule.Resources.Select (n => n.Name).ToList (); - - foreach (var resource in expectedResources) - Assert.IsTrue (actualResources.Contains (resource), "#1. " + resource); - Assert.AreEqual (expectedResources.Length, assemblyDef.MainModule.Resources.OfType ().Count (), "#2"); - } - - [Test] - public void GenerateBundleName_ExecutableProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - // Run a target that doesn't exist (since it's not possible to evaluate the csproj without running a target) - RunTarget (MonoTouchProject, "None", expectedErrorCount: 1); - - // Initially the AssemblyName is set and there is no app bundle dir - Assert.AreEqual ("MySingleView", MonoTouchProjectInstance.GetPropertyValue ("AssemblyName"), "#1"); - Assert.IsTrue (string.IsNullOrEmpty (MonoTouchProjectInstance.GetPropertyValue ("AppBundleDir")), "#2"); - - // Now we should have an AppBundleDir - RunTarget (MonoTouchProject, TargetName.GenerateBundleName); - Assert.AreEqual (@"bin/iPhoneSimulator/Debug/MySingleView.app", MonoTouchProjectInstance.GetPropertyValue ("AppBundleDir"), "#3"); - } - - [Test] - public void PackLibraryResources_ExecutableProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (MonoTouchProject, TargetName.PackLibraryResources); - var embeddedResources = MonoTouchProjectInstance.GetItems ("EmbeddedResource").ToArray (); - Assert.AreEqual (2, embeddedResources.Length, "#1"); - Assert.IsTrue (embeddedResources.Any (i => i.EvaluatedInclude == "LinkedEmbeddedResource.txt"), "#1"); - Assert.IsTrue (embeddedResources.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "EmbeddedResource.txt")), "#2"); - } - - [Test] - public void PackLibraryResources_LibraryProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (LibraryProject, TargetName.PackLibraryResources); - var embeddedResources = LibraryProjectInstance.GetItems ("EmbeddedResource").ToArray (); - Assert.AreEqual (13, embeddedResources.Length, "#1"); - } - - [Test] - public void UnpackLibraryResources_ExecutableProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - // We unpack 4 embedded resources from the library project into BundleResources - RunTarget (MonoTouchProject, TargetName.Build); - var bundleResources = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - Assert.That (bundleResources.Length, Is.GreaterThanOrEqualTo (30), "#1\n\t" + string.Join ("\n\t", bundleResources.Select (v => v.EvaluatedInclude))); - } - - [Test] - public void UnpackLibraryResources_LibraryProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - // We should not unpack any EmbeddedResources into BundleResources - RunTarget (LibraryProject, TargetName.Build); - var bundleResources = LibraryProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - Assert.AreEqual (11, bundleResources.Length, "#1"); - } - - [Test] - public void BundleResources () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var actool = Path.Combine ("obj", "iPhoneSimulator", "Debug", "actool", "bundle"); - var ibtool = Path.Combine ("obj", "iPhoneSimulator", "Debug", "ibtool"); - var path = Path.Combine (MonoTouchProjectPath, "Info.plist"); - var plist = PDictionary.FromFile (path); - - plist.SetMinimumOSVersion ("7.0"); - plist.Save (path, true); - - RunTarget (MonoTouchProject, TargetName.CollectBundleResources); - - var bundleItems = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - - var allBundleItems = "\n\t" + string.Join ("\n\t", bundleItems.Select (v => v.EvaluatedInclude)); - - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "BundleResource.txt") && i.GetMetadataValue ("LogicalName") == "Folder/BundleResource.txt"), "#1" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "Content.txt") && i.GetMetadataValue ("LogicalName") == "Folder/Content.txt"), "#2" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == "LinkedBundleResource.txt" && i.GetMetadataValue ("LogicalName") == "Folder/LinkedBundleResource.txt"), "#3" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == "LinkedContent.txt" && i.GetMetadataValue ("LogicalName") == "Folder/LinkedContent.txt"), "#4" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons60x60@2x.png"), "#10" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage-568h@2x.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage-568h@2x.png"), "#11" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage.png"), "#12" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (actool, "LaunchImage@2x.png") && i.GetMetadataValue ("LogicalName") == "LaunchImage@2x.png"), "#13" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "1-view-2.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/1-view-2.nib"), "#14" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "Info.plist") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/Info.plist"), "#15" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "MainStoryboard.storyboardc", "UIViewController-1.nib") && i.GetMetadataValue ("LogicalName") == "MainStoryboard.storyboardc/UIViewController-1.nib"), "#16" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "en.lproj", "TranslatedView.nib") && i.GetMetadataValue ("LogicalName") == "en.lproj/TranslatedView.nib"), "#17" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "FolderView.nib") && i.GetMetadataValue ("LogicalName") == "FolderView.nib"), "#18" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine (ibtool, "iPhoneView.nib") && i.GetMetadataValue ("LogicalName") == "iPhoneView.nib"), "#19" + allBundleItems); - Assert.IsTrue (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Resources", "image.png") && i.GetMetadataValue ("LogicalName") == "image.png"), "#20" + allBundleItems); - } - - [Test (Description = "Xambug #39137")] - public void AddAppIcon_NoClean () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var actool = Path.Combine ("obj", "iPhoneSimulator", "Debug", "actool", "bundle"); - var path = Path.Combine (MonoTouchProjectPath, "Info.plist"); - var plist = PDictionary.FromFile (path); - var plistCopy = PDictionary.FromFile (path); - - // Start without app icon. - plist.Remove ("XSAppIconAssets"); - plist.SetMinimumOSVersion ("7.0"); - plist.Save (path, true); - - RunTarget (MonoTouchProject, TargetName.CompileImageAssets, 0); - - var bundleItemsNoAppIcon = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsFalse (bundleItemsNoAppIcon.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons60x60@2x.png"), "#1"); - - // Put a thread.sleep so that we get noticeable timestamps. - EnsureFilestampChange (); - - // Re-save the original plist (adding app icon). - plistCopy.Save (path, true); - - // Re-run the task with app icon set this time and no clean. - // The task should be aware the app icon is now being used. - RunTarget (MonoTouchProject, TargetName.CompileImageAssets, 0); - - var bundleItemsWithAppIcon = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsTrue (bundleItemsWithAppIcon.Any (i => i.EvaluatedInclude == Path.Combine (actool, "AppIcons60x60@2x.png") && i.GetMetadataValue ("LogicalName") == "AppIcons60x60@2x.png"), "#2"); - } - - [Test (Description = "Xambug #16331")] - public void Disappearing_Bundle_Resource () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - string resource = Path.Combine (MonoTouchProjectPath, "Folder", "BundleResource.txt"); - string resourceGone = resource + ".disabled"; - try { - File.Move (resource, resourceGone); - RunTarget (MonoTouchProject, "_CollectBundleResources", expectedErrorCount: 1); - var bundleItems = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsNotNull (bundleItems, "#1"); - Assert.IsTrue (bundleItems.Length >= 17, "#2"); - Assert.IsFalse (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "BundleResource.txt")), "#3"); - } finally { - File.Move (resourceGone, resource); - } - } - - [Test (Description = "Xambug #16331")] - public void Disappearing_Content () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - string resource = Path.Combine (MonoTouchProjectPath, "Folder", "Content.txt"); - string resourceGone = resource + ".disabled"; - try { - File.Move (resource, resourceGone); - RunTarget (MonoTouchProject, "_CollectBundleResources", expectedErrorCount: 1); - var bundleItems = MonoTouchProjectInstance.GetItems ("_BundleResourceWithLogicalName").ToArray (); - Assert.IsNotNull (bundleItems, "#1"); - Assert.IsTrue (bundleItems.Length >= 17, "#2"); - Assert.IsFalse (bundleItems.Any (i => i.EvaluatedInclude == Path.Combine ("Folder", "Content.txt")), "#3"); - } finally { - File.Move (resourceGone, resource); - } - } - - [Test] - public void DetectAppManifest_ExecutableProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.That (MonoTouchProjectInstance.GetPropertyValue ("AppBundleManifest"), Is.Not.Null.And.Not.Empty, "#1"); - } - - [Test] - public void DetectAppManifest_ExecutableProject_NoPList () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - MonoTouchProjectInstance.RemoveItems ("None"); - - RunTarget (MonoTouchProject, TargetName.DetectAppManifest, expectedErrorCount: 1); - Assert.That (MonoTouchProjectInstance.GetPropertyValue ("AppBundleManifest"), Is.Null.Or.Empty, "#1"); - } - - [Test] - public void DetectAppManifest_ExecutableProject_TwoPLists () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - MonoTouchProjectInstance.RemoveItems ("None"); - - MonoTouchProjectInstance.AddItem ("None", "Fake/Info.plist"); - MonoTouchProjectInstance.AddItem ("None", "Info.plist"); - - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.AreEqual ("Info.plist", MonoTouchProjectInstance.GetPropertyValue ("AppBundleManifest"), "#1"); - } - - [Test] - public void DetectAppManifest_ExecutableProject_LinkedPList () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - string linkedPlist = CreateTempFile ("Linked.plist"); - - MonoTouchProjectInstance.RemoveItems ("None"); - - MonoTouchProjectInstance.AddItem ("None", linkedPlist, new Dictionary { { "Link", "Info.plist" } }); - - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.AreEqual (linkedPlist, MonoTouchProjectInstance.GetPropertyValue ("AppBundleManifest"), "#1"); - } - - [Test] - public void DetectAppManifest_ExecutableProject_LogicalNamePList () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - string logicalPlist = CreateTempFile ("Logical.plist"); - - MonoTouchProjectInstance.RemoveItems ("None"); - - MonoTouchProjectInstance.AddItem ("None", logicalPlist, new Dictionary { { "LogicalName", "Info.plist" } }); - - RunTarget (MonoTouchProject, TargetName.DetectAppManifest); - Assert.AreEqual (logicalPlist, MonoTouchProjectInstance.GetPropertyValue ("AppBundleManifest"), "#1"); - } - - [Test] - public void DetectAppManifest_LibraryProject () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - RunTarget (LibraryProject, TargetName.DetectAppManifest); - Assert.That (LibraryProjectInstance.GetPropertyValue ("AppBundleManifest"), Is.Null.Or.Empty, "#1"); - } } } diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/ValidateAppBundleTaskTests.cs b/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/ValidateAppBundleTaskTests.cs deleted file mode 100644 index 531699aea6bd..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/ValidateAppBundleTaskTests.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.IO; -using NUnit.Framework; - -using Microsoft.Build.Evaluation; - -using Xamarin.MacDev; - -using Xamarin.Tests; -using Xamarin.Utils; - -namespace Xamarin.MacDev.Tasks { - [TestFixture] - public class ValidateAppBundleTaskTests : ExtensionTestBase { - string extensionBundlePath; - string mainAppPlistPath; - string extensionPlistPath; - - public ValidateAppBundleTaskTests () - : base ("iPhoneSimulator") - { - } - - [Test] - public void MissingFiles () - { - Configuration.IgnoreIfIgnoredPlatform (ApplePlatform.iOS); - Configuration.AssertLegacyXamarinAvailable (); // Investigate whether this test should be ported to .NET - - var paths = BuildExtension ("MyTabbedApplication", "MyActionExtension"); - extensionBundlePath = paths.AppBundlePath; - mainAppPlistPath = Path.Combine (AppBundlePath, "Info.plist"); - extensionPlistPath = Path.Combine (extensionBundlePath, "Info.plist"); - - MissingPlist_Extension (); - MissingPlist_MainApp (); - NotMatching_VersionBuildNumbers (); - } - - void MissingPlist_MainApp () - { - var contents = File.ReadAllBytes (mainAppPlistPath); - try { - File.Delete (mainAppPlistPath); - RunTarget (MonoTouchProject, "_ValidateAppBundle", 1); - Assert.IsTrue (Engine.Logger.ErrorEvents.Count > 0, "#2"); - } finally { - // Restore the contents - File.WriteAllBytes (mainAppPlistPath, contents); - } - } - - void MissingPlist_Extension () - { - var contents = File.ReadAllBytes (extensionPlistPath); - try { - File.Delete (extensionPlistPath); - RunTarget (MonoTouchProject, "_ValidateAppBundle", 1); - Assert.IsTrue (Engine.Logger.ErrorEvents.Count > 0, "#2"); - } finally { - // Restore the contents - File.WriteAllBytes (extensionPlistPath, contents); - } - } - - // Xambug #38673 - void NotMatching_VersionBuildNumbers () - { - var contents = File.ReadAllBytes (mainAppPlistPath); - var sourcePlist = PDictionary.FromFile (mainAppPlistPath); - try { - // Warning: The App Extension has a CFBundleShortVersionString - // that does not match the main app bundle's CFBundleShortVersionString. - sourcePlist.SetCFBundleShortVersionString ("1"); - - // Warning: The App Extension has a CFBundleVersion - // that does not match the main app bundle's CFBundleVersion. - sourcePlist.SetCFBundleVersion ("1"); - - sourcePlist.Save (mainAppPlistPath); - RunTarget (MonoTouchProject, "_ValidateAppBundle", 0); - Assert.AreEqual (2, Engine.Logger.WarningsEvents.Count, "#2"); - } finally { - // Restore the contents - File.WriteAllBytes (mainAppPlistPath, contents); - } - } - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/BuildEngine.cs b/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/BuildEngine.cs index f89ef2500cc2..fa11d3cbf44a 100644 --- a/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/BuildEngine.cs +++ b/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/BuildEngine.cs @@ -30,26 +30,15 @@ public void SetGlobalProperty (string name, string value) ExecutionResult? executionResult; - public ExecutionResult RunTarget (ApplePlatform platform, ExecutionMode mode, string project, string target, Dictionary? properties = null) + public ExecutionResult RunTarget (ApplePlatform platform, string project, string target, Dictionary? properties = null) { - ExecutionResult rv; - var props = new Dictionary (Properties); if (properties is not null) { foreach (var kvp in properties) props [kvp.Key] = kvp.Value; } - switch (mode) { - case ExecutionMode.MSBuild: - rv = MSBuild (platform, project, target, props); - break; - case ExecutionMode.DotNet: - rv = Dotnet (project, "Build", target, props); - break; - default: - throw new InvalidOperationException ($"Unknown execution mode: {mode}"); - } + var rv = Dotnet (project, "Build", target, props); executionResult = rv; diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/ExecutionMode.cs b/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/ExecutionMode.cs deleted file mode 100644 index 180744482465..000000000000 --- a/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/ExecutionMode.cs +++ /dev/null @@ -1,9 +0,0 @@ -#nullable enable - -namespace Xamarin.Tests { - public enum ExecutionMode { - None, - MSBuild, - DotNet, - } -} diff --git a/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/TestBase.cs b/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/TestBase.cs index cefddb0a7378..8cfb87ceba4f 100644 --- a/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/TestBase.cs +++ b/tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/TestBase.cs @@ -11,7 +11,6 @@ namespace Xamarin.Tests { public abstract class TestBase { - public ExecutionMode Mode = ExecutionMode.MSBuild; public string Platform; public string Config = "Debug"; @@ -43,31 +42,6 @@ protected static class TargetName { public static string ResolveReferences = "ResolveReferences"; } - string testDirectory; - - protected void ClearTestDirectory () - { - testDirectory = null; - } - - protected string GetTestDirectory (bool forceClone = false) - { - if (testDirectory is null || forceClone) - testDirectory = CloneTestDirectory (Mode); - return testDirectory; - } - - static string CloneTestDirectory (ExecutionMode mode) - { - var rv = Configuration.CloneTestDirectory (Configuration.TestProjectsDirectory); - - if (mode == ExecutionMode.DotNet) { - Configuration.FixupTestFiles (rv, "dotnet"); - } - - return rv; - } - public string [] ExpectedAppFiles = { }; public string [] UnexpectedAppFiles = { "monotouch.dll" }; @@ -117,79 +91,9 @@ public MSBuildProject LibraryProjectInstance { public string MonoTouchProjectPath => MonoTouchProject.ProjectPath; public string AppBundlePath => MonoTouchProject.AppBundlePath; - // project can be: - // * an absolute path to a project - // * a relative path to a project directory inside the tests/common/TestProjects directory. - // in this case the project's name is assumed from the name of the project directory - public ProjectPaths SetupProjectPaths (string project, bool? includePlatform = null) - { - if (project is null) - throw new ArgumentNullException (nameof (project)); - - string projectPath; - string projectName; - string csprojPath; - if (Path.IsPathRooted (project)) { - projectPath = Path.GetDirectoryName (project); - projectName = Path.GetFileNameWithoutExtension (project); - csprojPath = project; - } else { - projectPath = Path.Combine (GetTestDirectory (), project); - projectName = Path.GetFileNameWithoutExtension (project); - csprojPath = Path.Combine (projectPath, projectName + ".csproj"); - } - - if (!File.Exists (csprojPath)) - throw new InvalidOperationException ($"Can't resolve the project {project}"); - - string binPath; - string objPath; - - if (includePlatform == false || (includePlatform is null && string.IsNullOrEmpty (Platform))) { - binPath = Path.Combine (projectPath, "bin", Config); - objPath = Path.Combine (projectPath, "obj", Config); - } else { - binPath = Path.Combine (projectPath, "bin", Platform, Config); - objPath = Path.Combine (projectPath, "obj", Platform, Config); - } - - if (Mode == ExecutionMode.DotNet) { - var targetPlatform = Configuration.DotNetTfm; - var subdir = string.Empty; - var targetPlatformSuffix = string.Empty; - var isDevice = Platform == "iPhone"; - switch (TargetFrameworkIdentifier) { - case "Xamarin.iOS": - subdir = isDevice ? "ios-arm64" : "iossimulator-x64"; - targetPlatformSuffix = "ios"; - break; - case "Xamarin.TVOS": - subdir = isDevice ? "tvos-arm64" : "tvossimulator-x64"; - targetPlatformSuffix = "tvos"; - break; - default: - throw new NotImplementedException ($"Unknown TargetFrameworkIdentifier: {TargetFrameworkIdentifier}"); - } - targetPlatform += "-" + targetPlatformSuffix; - binPath = Path.Combine (binPath, targetPlatform, subdir); - objPath = Path.Combine (objPath, targetPlatform, subdir); - } - - return new ProjectPaths { - ProjectPath = projectPath, - ProjectBinPath = binPath, - ProjectObjPath = objPath, - ProjectCSProjPath = csprojPath, - AppBundlePath = Path.Combine (binPath, projectName.Replace (" ", "") + ".app"), - }; - } - [SetUp] public virtual void Setup () { - //testDirectory = GetTestDirectory (forceClone: true); - //MonoTouchProject = SetupProjectPaths ("MySingleView"); - //LibraryProject = SetupProjectPaths ("MySingleView/MyLibrary", false); //MonoTouchProjectInstance = new MSBuildProject (MonoTouchProject, this); //LibraryProjectInstance = new MSBuildProject (LibraryProject, this); @@ -300,14 +204,9 @@ public static void EnsureFilestampChange () Thread.Sleep (1000); } - public void RunTarget (ProjectPaths paths, string target, int expectedErrorCount) - { - RunTarget (paths, target, null, expectedErrorCount); - } - - public void RunTarget (ProjectPaths paths, string target, ExecutionMode? executionMode = null, int expectedErrorCount = 0, Dictionary properties = null) + public void RunTarget (ProjectPaths paths, string target, int expectedErrorCount = 0, Dictionary properties = null) { - var rv = Engine.RunTarget (ApplePlatform, executionMode ?? Mode, paths.ProjectCSProjPath, target, properties); + var rv = Engine.RunTarget (ApplePlatform, paths.ProjectCSProjPath, target, properties); if (expectedErrorCount != Engine.ErrorEvents.Count) { foreach (var e in Engine.ErrorEvents) Console.WriteLine (e.ToString ());