From 80d458519f8a8bedcd22fde07b94699050f4b9cd Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Tue, 28 Jan 2020 15:40:52 -0500 Subject: [PATCH] [SampleTester] Add 4 new samples (#7758) * [SampleTester] Add 4 new samples New samples added: * https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/Xaminals * https://github.com/davidortinau/Xappy * https://github.com/Microsoft/SmartHotel360-Mobile * https://github.com/microsoft/ConferenceVision * Update new samples known failures * Add timeout option and removed extra not needed data * Fix whitespaces... * Disable Xappy and add CodesignKey option CodesignKey allows you to use and set it per csproj basis. Xappy is failing on the UWP csproj, we diable it for now until we add a way to remove certain projects. * Update tests/sampletester/ProcessHelper.cs Co-Authored-By: Rolf Bjarne Kvinge Co-authored-by: Rolf Bjarne Kvinge --- tests/sampletester/ProcessHelper.cs | 8 ++-- tests/sampletester/SampleTester.cs | 13 +++-- tests/sampletester/Samples.cs | 73 +++++++++++++++++++++++++---- 3 files changed, 79 insertions(+), 15 deletions(-) diff --git a/tests/sampletester/ProcessHelper.cs b/tests/sampletester/ProcessHelper.cs index b44ee7214f..a59c8a1b29 100644 --- a/tests/sampletester/ProcessHelper.cs +++ b/tests/sampletester/ProcessHelper.cs @@ -75,7 +75,7 @@ public static class ProcessHelper Assert.AreEqual (0, exitCode, $"{message} failed (unexpected exit code){errorMessage}"); } - public static void BuildSolution (string solution, string platform, string configuration, Dictionary environment_variables, string target = "") + public static void BuildSolution (string solution, string platform, string configuration, Dictionary environment_variables, TimeSpan timeout, string target = "", string codesignKey = null) { // nuget restore var solution_dir = string.Empty; @@ -95,7 +95,7 @@ public static class ProcessHelper foreach (var sln in solutions) { nuget_args [1] = sln; // replacing here - AssertRunProcess ("nuget", nuget_args.ToArray (), TimeSpan.FromMinutes (5), Configuration.SampleRootDirectory, environment_variables, "nuget restore"); + AssertRunProcess ("nuget", nuget_args.ToArray (), timeout, Configuration.SampleRootDirectory, environment_variables, "nuget restore"); } // msbuild @@ -108,6 +108,8 @@ public static class ProcessHelper sb.Add (solution); if (!string.IsNullOrEmpty (target)) sb.Add ($"/t:{target}"); + if (!string.IsNullOrEmpty (codesignKey)) + sb.Add ($"/p:CodesignKey={codesignKey}"); environment_variables ["MTOUCH_ENV_OPTIONS"] = "--time --time --time --time -vvvv"; environment_variables ["MMP_ENV_OPTIONS"] = "--time --time --time --time -vvvv"; @@ -116,7 +118,7 @@ public static class ProcessHelper var failed = false; string msbuild_logfile; try { - AssertRunProcess ("msbuild", sb.ToArray (), TimeSpan.FromMinutes (5), Configuration.SampleRootDirectory, environment_variables, "build", out msbuild_logfile); + AssertRunProcess ("msbuild", sb.ToArray (), timeout, Configuration.SampleRootDirectory, environment_variables, "build", out msbuild_logfile); } catch { failed = true; throw; diff --git a/tests/sampletester/SampleTester.cs b/tests/sampletester/SampleTester.cs index 6c83f706e1..98fe535028 100644 --- a/tests/sampletester/SampleTester.cs +++ b/tests/sampletester/SampleTester.cs @@ -14,6 +14,7 @@ namespace Samples { public string Solution; public bool BuildSolution; public string KnownFailure; + public string CodesignKey; public string[] DebugConfigurations; public string[] ReleaseConfigurations; public string[] Platforms; @@ -23,6 +24,7 @@ namespace Samples { public SampleTest SampleTest; public string Configuration; public string Platform; + public TimeSpan Timeout; public override string ToString () { @@ -66,6 +68,9 @@ namespace Samples { } public abstract class SampleTester : BaseTester { + + public static TimeSpan DefaultTimeout { get; } = TimeSpan.FromMinutes (5); + protected SampleTester () { } @@ -142,7 +147,7 @@ namespace Samples { } file_to_build = Path.Combine (CloneRepo (), file_to_build); - ProcessHelper.BuildSolution (file_to_build, sampleTestData.Platform, sampleTestData.Configuration, environment_variables, target); + ProcessHelper.BuildSolution (file_to_build, sampleTestData.Platform, sampleTestData.Configuration, environment_variables, sampleTestData.Timeout, target, data.CodesignKey); Console.WriteLine ("✅ {0} succeeded.", TestContext.CurrentContext.Test.FullName); } catch (Exception e) { Console.WriteLine ("❌ {0} failed: {1}", TestContext.CurrentContext.Test.FullName, e.Message); @@ -167,7 +172,7 @@ namespace Samples { return rv; } - protected static IEnumerable GetSampleTestData (Dictionary samples, string org, string repo, string hash) + protected static IEnumerable GetSampleTestData (Dictionary samples, string org, string repo, string hash, TimeSpan timeout) { var defaultDebugConfigurations = new string [] { "Debug" }; var defaultReleaseConfigurations = new string [] { "Release" }; @@ -236,7 +241,7 @@ namespace Samples { configs.AddRange (sample.DebugConfigurations ?? defaultDebugConfigurations); configs.AddRange (sample.ReleaseConfigurations ?? defaultReleaseConfigurations); foreach (var config in filter ("config", proj.Title, configs, config_filter, (v) => v)) { - yield return new SampleTestData { SampleTest = sample, Configuration = config, Platform = platform }; + yield return new SampleTestData { SampleTest = sample, Configuration = config, Platform = platform, Timeout = timeout }; } } } @@ -255,7 +260,7 @@ namespace Samples { { var sln = Path.Combine (Configuration.SourceRoot, "tests", "sampletester", "BaselineTest", "BaselineTest.sln"); GitHub.CleanRepository (Path.GetDirectoryName (sln)); - ProcessHelper.BuildSolution (sln, "iPhone", "Debug", new Dictionary ()); + ProcessHelper.BuildSolution (sln, "iPhone", "Debug", new Dictionary (), SampleTester.DefaultTimeout); } } diff --git a/tests/sampletester/Samples.cs b/tests/sampletester/Samples.cs index f74342a1c1..f413d8089f 100644 --- a/tests/sampletester/Samples.cs +++ b/tests/sampletester/Samples.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using NUnit.Framework; @@ -44,7 +45,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -65,7 +66,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -81,7 +82,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -115,7 +116,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -133,7 +134,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -151,7 +152,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -175,7 +176,7 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } } @@ -193,7 +194,63 @@ namespace Samples { static IEnumerable GetSampleData () { - return GetSampleTestData (test_data, ORG, REPO, HASH); + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); + } + } + + // TODO: Reenable once we can ignore specific projects + // Xappy.UWP.csproj : error MSB4057: The target "_IsProjectRestoreSupported" does not exist in the project. + //[Category (CATEGORY)] + //public class XappyTester : SampleTester { + // const string ORG = "davidortinau"; + // const string REPO = "Xappy"; + // const string CATEGORY = "davidortinauxappy"; // categories can't contain dashes + // const string HASH = "46e5897bac974e000fcc7e1d10d01ab8d3072eb2"; + + // static Dictionary test_data = new Dictionary { + // // Known failures + // { "Xappy/Xappy.UWP/Xappy.UWP.csproj", new SampleTest { BuildSolution = true, Solution = "Xappy.sln", KnownFailure = "The target \"_IsProjectRestoreSupported\" does not exist in the project." } }, + // }; + + // static IEnumerable GetSampleData () + // { + // return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); + // } + //} + + [Category (CATEGORY)] + public class SmartHotelTester : SampleTester { + const string ORG = "microsoft"; + const string REPO = "SmartHotel360-Mobile"; + const string CATEGORY = "microsoftsmarthotel"; // categories can't contain dashes + const string HASH = "4004b32c955f8340a0306bad2b180ecf5adaf117"; + + static Dictionary test_data = new Dictionary { + // Override CodesignKey key + { "Source/SmartHotel.Clients/SmartHotel.Clients.iOS/SmartHotel.Clients.iOS.csproj", new SampleTest { CodesignKey = "iPhone Developer" } }, + { "Source/SmartHotel.Clients.Maintenance/SmartHotel.Clients.Maintenance.iOS/SmartHotel.Clients.Maintenance.iOS.csproj", new SampleTest { CodesignKey = "iPhone Developer" } }, + }; + + static IEnumerable GetSampleData () + { + return GetSampleTestData (test_data, ORG, REPO, HASH, timeout: TimeSpan.FromMinutes (10)); + } + } + + [Category (CATEGORY)] + public class ConferenceVisionTester : SampleTester { + const string ORG = "microsoft"; + const string REPO = "ConferenceVision"; + const string CATEGORY = "microsoftconferencevision"; // categories can't contain dashes + const string HASH = "b477f99c9e23097b31168697b2c168e90c34fd4d"; + + static Dictionary test_data = new Dictionary { + + }; + + static IEnumerable GetSampleData () + { + return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout); } }