[xharness] Add a new test variation for xammac tests: release with all optimizations enabled.

This commit is contained in:
Rolf Bjarne Kvinge 2018-02-13 13:27:56 +01:00
Родитель ea3316465b
Коммит 0af9a6744d
3 изменённых файлов: 63 добавлений и 14 удалений

Просмотреть файл

@ -83,7 +83,9 @@ namespace MonoTouchFixtures.Foundation {
{
Assert.Null (NSData.FromFile ("does not exists"), "unexisting");
#if MONOMAC // Info.Plist isn't there to load from the same location on mac
#if !LINKALL
Assert.NotNull (NSData.FromFile (NSBundle.MainBundle.PathForResource ("runtime-options", "plist")), "runtime-options.plist");
#endif
#else
Assert.NotNull (NSData.FromFile ("Info.plist"), "Info.plist");
#endif

Просмотреть файл

@ -151,8 +151,11 @@ namespace xharness
{
public string Variation;
public string MTouchExtraArgs;
public string MonoBundlingExtraArgs; // mmp
public bool Debug;
public bool Profiling;
public string LinkMode;
public string Defines;
}
IEnumerable<TestData> GetTestData (RunTestTask test)
@ -179,6 +182,15 @@ namespace xharness
break;
}
break;
case "AnyCPU":
case "x86":
switch (test.TestName) {
case "xammac tests":
if (test.ProjectConfiguration == "Release")
yield return new TestData { Variation = "Release (all optimizations)", MonoBundlingExtraArgs = "--registrar:static --optimize:all", Debug = false, LinkMode = "Full", Defines = "LINKALL" };
break;
}
break;
default:
throw new NotImplementedException (test.ProjectPlatform);
}
@ -196,9 +208,12 @@ namespace xharness
foreach (var test_data in GetTestData (task)) {
var variation = test_data.Variation;
var mtouch_extra_args = test_data.MTouchExtraArgs;
var bundling_extra_args = test_data.MonoBundlingExtraArgs;
var configuration = test_data.Debug ? task.ProjectConfiguration : task.ProjectConfiguration.Replace ("Debug", "Release");
var debug = test_data.Debug;
var profiling = test_data.Profiling;
var link_mode = test_data.LinkMode;
var defines = test_data.Defines;
var clone = task.TestProject.Clone ();
var clone_task = Task.Run (async () => {
@ -206,8 +221,26 @@ namespace xharness
await clone.CreateCopyAsync (task);
if (!string.IsNullOrEmpty (mtouch_extra_args))
clone.Xml.AddExtraMtouchArgs (mtouch_extra_args, task.ProjectPlatform, configuration);
clone.Xml.SetNode ("MTouchProfiling", profiling ? "True" : "False", task.ProjectPlatform, configuration);
if (!debug)
if (!string.IsNullOrEmpty (bundling_extra_args))
clone.Xml.AddMonoBundlingExtraArgs (bundling_extra_args, task.ProjectPlatform, configuration);
if (!string.IsNullOrEmpty (link_mode))
clone.Xml.SetNode ("LinkMode", link_mode, task.ProjectPlatform, configuration);
if (!string.IsNullOrEmpty (defines))
clone.Xml.AddAdditionalDefines (defines, task.ProjectPlatform, configuration);
var isMac = false;
switch (task.Platform) {
case TestPlatform.Mac:
case TestPlatform.Mac_Classic:
case TestPlatform.Mac_Unified:
case TestPlatform.Mac_Unified32:
case TestPlatform.Mac_UnifiedXM45:
case TestPlatform.Mac_UnifiedXM45_32:
isMac = true;
break;
}
clone.Xml.SetNode (isMac ? "Profiling" : "MTouchProfiling", profiling ? "True" : "False", task.ProjectPlatform, configuration);
if (!debug && !isMac)
clone.Xml.SetMtouchUseLlvm (true, task.ProjectPlatform, configuration);
clone.Xml.Save (clone.Path);
});
@ -611,6 +644,7 @@ namespace xharness
build.SpecifyPlatform = false;
build.SpecifyConfiguration = build.ProjectConfiguration != "Debug";
RunTestTask exec;
IEnumerable<RunTestTask> execs;
if (project.IsNUnitProject) {
var dll = Path.Combine (Path.GetDirectoryName (build.TestProject.Path), project.Xml.GetOutputAssemblyPath (build.ProjectPlatform, build.ProjectConfiguration).Replace ('\\', '/'));
exec = new NUnitExecuteTask (build) {
@ -622,6 +656,7 @@ namespace xharness
TestName = project.Name,
Timeout = TimeSpan.FromMinutes (120),
};
execs = new [] { exec };
} else {
exec = new MacExecuteTask (build) {
Ignored = ignored || !IncludeClassicMac,
@ -629,16 +664,19 @@ namespace xharness
TestName = project.Name,
IsUnitTest = true,
};
execs = CreateTestVariations (new [] { exec }, (buildTask, test) => new MacExecuteTask (buildTask));
}
exec.Variation = configurations.Length > 1 ? config : project.TargetFrameworkFlavor.ToString ();
Tasks.Add (exec);
if (project.GenerateVariations) {
Tasks.Add (CloneExecuteTask (exec, project, TestPlatform.Mac_Unified, "-unified", ignored));
Tasks.Add (CloneExecuteTask (exec, project, TestPlatform.Mac_Unified32, "-unified-32", ignored));
if (project.GenerateFull) {
Tasks.Add (CloneExecuteTask (exec, project, TestPlatform.Mac_UnifiedXM45, "-unifiedXM45", ignored));
Tasks.Add (CloneExecuteTask (exec, project, TestPlatform.Mac_UnifiedXM45_32, "-unifiedXM45-32", ignored));
Tasks.AddRange (execs);
foreach (var e in execs) {
if (project.GenerateVariations) {
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified, "-unified", ignored));
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified32, "-unified-32", ignored));
if (project.GenerateFull) {
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_UnifiedXM45, "-unifiedXM45", ignored));
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_UnifiedXM45_32, "-unifiedXM45-32", ignored));
}
}
}
}

Просмотреть файл

@ -324,9 +324,19 @@ namespace xharness
public static void AddExtraMtouchArgs (this XmlDocument csproj, string value, string platform, string configuration)
{
var mtouchExtraArgs = csproj.SelectNodes ("//*[local-name() = 'MtouchExtraArgs']");
AddToNode (csproj, "MTouchExtraArgs", value, platform, configuration);
}
public static void AddMonoBundlingExtraArgs (this XmlDocument csproj, string value, string platform, string configuration)
{
AddToNode (csproj, "MonoBundlingExtraArgs", value, platform, configuration);
}
public static void AddToNode (this XmlDocument csproj, string node, string value, string platform, string configuration)
{
var nodes = csproj.SelectNodes ($"//*[local-name() = '{node}']");
var found = false;
foreach (XmlNode mea in mtouchExtraArgs) {
foreach (XmlNode mea in nodes) {
if (!IsNodeApplicable (mea, platform, configuration))
continue;
@ -337,18 +347,17 @@ namespace xharness
if (found)
return;
// Not all projects have a MtouchExtraArgs node, so create one of none was found.
// The project might not have this node, so create one of none was found.
var propertyGroups = csproj.SelectNodes ("//*[local-name() = 'PropertyGroup' and @Condition]");
foreach (XmlNode pg in propertyGroups) {
if (!EvaluateCondition (pg, platform, configuration))
continue;
var mea = csproj.CreateElement ("MtouchExtraArgs", MSBuild_Namespace);
var mea = csproj.CreateElement (node, MSBuild_Namespace);
mea.InnerText = value;
pg.AppendChild (mea);
}
}
public static string GetExtraMtouchArgs (this XmlDocument csproj, string platform, string configuration)
{
var mtouchExtraArgs = csproj.SelectNodes ("//*[local-name() = 'MtouchExtraArgs']");