From 4c990affe7246eb771c0a21a5784d40e29a3a170 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 20 Jun 2019 08:27:45 +0200 Subject: [PATCH] [xharness] Don't depend on the Harness.Mac value except to determine what to configure. Currently we execute most of the same logic both during the configure phase and when running tests, and the Harness.Mac value is only set in the configure phase. While it doesn't matter right now, this makes sure there aren't any future surprises in this area, since otherwise we could end up with different behavior between the configure phase and when running tests. --- tests/xharness/MacTarget.cs | 8 ++++++++ tests/xharness/Target.cs | 27 +++++++++------------------ tests/xharness/iOSTarget.cs | 28 +++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/tests/xharness/MacTarget.cs b/tests/xharness/MacTarget.cs index 031c6f9289..94edc0577c 100644 --- a/tests/xharness/MacTarget.cs +++ b/tests/xharness/MacTarget.cs @@ -186,5 +186,13 @@ namespace xharness return null; } } + + protected override void PostProcessExecutableProject () + { + base.PostProcessExecutableProject (); + + ProjectGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}"; + inputProject.SetProjectGuid (ProjectGuid); + } } } diff --git a/tests/xharness/Target.cs b/tests/xharness/Target.cs index da52fdfb70..615c7152ae 100644 --- a/tests/xharness/Target.cs +++ b/tests/xharness/Target.cs @@ -120,27 +120,18 @@ namespace xharness protected void CreateExecutableProject () { ProcessProject (); - if (Harness.Mac) { - ProjectGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}"; - inputProject.SetProjectGuid (ProjectGuid); - } else { - inputProject.FixArchitectures (SimulatorArchitectures, DeviceArchitectures); - inputProject.FixInfoPListInclude (Suffix); - inputProject.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml"); - } + PostProcessExecutableProject (); Harness.Save (inputProject, ProjectPath); - if (!Harness.Mac) { - ProjectGuid = inputProject.GetProjectGuid (); + UpdateInfoPList (); + } - XmlDocument info_plist = new XmlDocument (); - var target_info_plist = Path.Combine (TargetDirectory, "Info" + Suffix + ".plist"); - info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info.plist")); - BundleIdentifier = info_plist.GetCFBundleIdentifier (); - info_plist.SetMinimumOSVersion (GetMinimumOSVersion (info_plist.GetMinimumOSVersion ())); - info_plist.SetUIDeviceFamily (UIDeviceFamily); - Harness.Save (info_plist, target_info_plist); - } + protected virtual void PostProcessExecutableProject () + { + } + + protected virtual void UpdateInfoPList () + { } protected void CreateLibraryProject () diff --git a/tests/xharness/iOSTarget.cs b/tests/xharness/iOSTarget.cs index a29d4d5523..81304a50fc 100644 --- a/tests/xharness/iOSTarget.cs +++ b/tests/xharness/iOSTarget.cs @@ -1,4 +1,7 @@ -using System; +using System.IO; +using System.Xml; + +using Xamarin; namespace xharness { @@ -8,5 +11,28 @@ namespace xharness public iOSTestProject TestProject; public MonoNativeInfo MonoNativeInfo => TestProject.MonoNativeInfo; + + protected override void PostProcessExecutableProject () + { + base.PostProcessExecutableProject (); + + inputProject.FixArchitectures (SimulatorArchitectures, DeviceArchitectures); + inputProject.FixInfoPListInclude (Suffix); + inputProject.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml"); + + ProjectGuid = inputProject.GetProjectGuid (); + } + + protected override void UpdateInfoPList () + { + XmlDocument info_plist = new XmlDocument (); + var target_info_plist = Path.Combine (TargetDirectory, "Info" + Suffix + ".plist"); + info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info.plist")); + BundleIdentifier = info_plist.GetCFBundleIdentifier (); + info_plist.SetMinimumOSVersion (GetMinimumOSVersion (info_plist.GetMinimumOSVersion ())); + info_plist.SetUIDeviceFamily (UIDeviceFamily); + Harness.Save (info_plist, target_info_plist); + } } } +