[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 <rolf@xamarin.com>

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This commit is contained in:
Alex Soto 2020-01-28 15:40:52 -05:00 коммит произвёл Sebastien Pouliot
Родитель 889473ec07
Коммит 80d458519f
3 изменённых файлов: 79 добавлений и 15 удалений

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

@ -75,7 +75,7 @@ public static class ProcessHelper
Assert.AreEqual (0, exitCode, $"{message} failed (unexpected exit code){errorMessage}"); Assert.AreEqual (0, exitCode, $"{message} failed (unexpected exit code){errorMessage}");
} }
public static void BuildSolution (string solution, string platform, string configuration, Dictionary<string, string> environment_variables, string target = "") public static void BuildSolution (string solution, string platform, string configuration, Dictionary<string, string> environment_variables, TimeSpan timeout, string target = "", string codesignKey = null)
{ {
// nuget restore // nuget restore
var solution_dir = string.Empty; var solution_dir = string.Empty;
@ -95,7 +95,7 @@ public static class ProcessHelper
foreach (var sln in solutions) { foreach (var sln in solutions) {
nuget_args [1] = sln; // replacing here 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 // msbuild
@ -108,6 +108,8 @@ public static class ProcessHelper
sb.Add (solution); sb.Add (solution);
if (!string.IsNullOrEmpty (target)) if (!string.IsNullOrEmpty (target))
sb.Add ($"/t:{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 ["MTOUCH_ENV_OPTIONS"] = "--time --time --time --time -vvvv";
environment_variables ["MMP_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; var failed = false;
string msbuild_logfile; string msbuild_logfile;
try { 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 { } catch {
failed = true; failed = true;
throw; throw;

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

@ -14,6 +14,7 @@ namespace Samples {
public string Solution; public string Solution;
public bool BuildSolution; public bool BuildSolution;
public string KnownFailure; public string KnownFailure;
public string CodesignKey;
public string[] DebugConfigurations; public string[] DebugConfigurations;
public string[] ReleaseConfigurations; public string[] ReleaseConfigurations;
public string[] Platforms; public string[] Platforms;
@ -23,6 +24,7 @@ namespace Samples {
public SampleTest SampleTest; public SampleTest SampleTest;
public string Configuration; public string Configuration;
public string Platform; public string Platform;
public TimeSpan Timeout;
public override string ToString () public override string ToString ()
{ {
@ -66,6 +68,9 @@ namespace Samples {
} }
public abstract class SampleTester : BaseTester { public abstract class SampleTester : BaseTester {
public static TimeSpan DefaultTimeout { get; } = TimeSpan.FromMinutes (5);
protected SampleTester () protected SampleTester ()
{ {
} }
@ -142,7 +147,7 @@ namespace Samples {
} }
file_to_build = Path.Combine (CloneRepo (), file_to_build); 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); Console.WriteLine ("✅ {0} succeeded.", TestContext.CurrentContext.Test.FullName);
} catch (Exception e) { } catch (Exception e) {
Console.WriteLine ("❌ {0} failed: {1}", TestContext.CurrentContext.Test.FullName, e.Message); Console.WriteLine ("❌ {0} failed: {1}", TestContext.CurrentContext.Test.FullName, e.Message);
@ -167,7 +172,7 @@ namespace Samples {
return rv; return rv;
} }
protected static IEnumerable<SampleTestData> GetSampleTestData (Dictionary<string, SampleTest> samples, string org, string repo, string hash) protected static IEnumerable<SampleTestData> GetSampleTestData (Dictionary<string, SampleTest> samples, string org, string repo, string hash, TimeSpan timeout)
{ {
var defaultDebugConfigurations = new string [] { "Debug" }; var defaultDebugConfigurations = new string [] { "Debug" };
var defaultReleaseConfigurations = new string [] { "Release" }; var defaultReleaseConfigurations = new string [] { "Release" };
@ -236,7 +241,7 @@ namespace Samples {
configs.AddRange (sample.DebugConfigurations ?? defaultDebugConfigurations); configs.AddRange (sample.DebugConfigurations ?? defaultDebugConfigurations);
configs.AddRange (sample.ReleaseConfigurations ?? defaultReleaseConfigurations); configs.AddRange (sample.ReleaseConfigurations ?? defaultReleaseConfigurations);
foreach (var config in filter ("config", proj.Title, configs, config_filter, (v) => v)) { 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"); var sln = Path.Combine (Configuration.SourceRoot, "tests", "sampletester", "BaselineTest", "BaselineTest.sln");
GitHub.CleanRepository (Path.GetDirectoryName (sln)); GitHub.CleanRepository (Path.GetDirectoryName (sln));
ProcessHelper.BuildSolution (sln, "iPhone", "Debug", new Dictionary<string, string> ()); ProcessHelper.BuildSolution (sln, "iPhone", "Debug", new Dictionary<string, string> (), SampleTester.DefaultTimeout);
} }
} }

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

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
@ -44,7 +45,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -65,7 +66,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -81,7 +82,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -115,7 +116,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -133,7 +134,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -151,7 +152,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -175,7 +176,7 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> GetSampleData ()
{ {
return GetSampleTestData (test_data, ORG, REPO, HASH); return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }
@ -193,7 +194,63 @@ namespace Samples {
static IEnumerable<SampleTestData> GetSampleData () static IEnumerable<SampleTestData> 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<string, SampleTest> test_data = new Dictionary<string, SampleTest> {
// // 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<SampleTestData> 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<string, SampleTest> test_data = new Dictionary<string, SampleTest> {
// 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<SampleTestData> 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<string, SampleTest> test_data = new Dictionary<string, SampleTest> {
};
static IEnumerable<SampleTestData> GetSampleData ()
{
return GetSampleTestData (test_data, ORG, REPO, HASH, DefaultTimeout);
} }
} }