Skip to content

Commit

Permalink
devops xamarin#16.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Mar 28, 2019
1 parent a4c49dc commit 77f905e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
23 changes: 22 additions & 1 deletion devops/build-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,28 @@ trigger:

jobs:
- job: macOS
displayName: xamarin macios
displayName: Build samples
timeoutInMinutes: 360
strategy:
matrix:
Debug|iPhone:
TEST_PLATFORM_FILTER_EXPRESSION: '^iPhone$'
TEST_CONFIG_FILTER_EXPRESSION: '^.*Debug.*$'
Debug|iPhoneSimulator:
TEST_PLATFORM_FILTER_EXPRESSION: '^iPhoneSimulator$'
TEST_CONFIG_FILTER_EXPRESSION: '^.*Debug.*$'
Release|iPhone:
TEST_PLATFORM_FILTER_EXPRESSION: '^iPhone$'
TEST_CONFIG_FILTER_EXPRESSION: '^.*Release.*$'
Release|iPhoneSimulator:
TEST_PLATFORM_FILTER_EXPRESSION: '^iPhoneSimulator$'
TEST_CONFIG_FILTER_EXPRESSION: '^.*Release.*$'
Debug|Mac:
TEST_PLATFORM_FILTER_EXPRESSION: '^$'
TEST_CONFIG_FILTER_EXPRESSION: '^.*Debug.*$'
Release|Mac:
TEST_PLATFORM_FILTER_EXPRESSION: '^$'
TEST_CONFIG_FILTER_EXPRESSION: '^.*Release.*$'

pool:
vmImage: 'macOS-10.13'
Expand Down Expand Up @@ -43,3 +63,4 @@ jobs:
testResultsFiles: '**/TestResult*.xml'
testRunTitle: Sample tests (build)
publishRunAttachments: true
mergeTestResults: true
26 changes: 23 additions & 3 deletions tests/sampletester/SampleTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;

using NUnit.Framework;

Expand Down Expand Up @@ -186,12 +187,29 @@ protected static IEnumerable<SampleTestData> GetSampleTestData (Dictionary<strin
}
}

var platform_filter = Environment.GetEnvironmentVariable ("TEST_PLATFORM_FILTER_EXPRESSION");
var config_filter = Environment.GetEnvironmentVariable ("TEST_CONFIG_FILTER_EXPRESSION");

IEnumerable<string> filter (string name, string proj, IEnumerable<string> input, string filter_expression)
{
if (string.IsNullOrEmpty (filter_expression))
return input;

var filtered = input.Where ((v) => Regex.IsMatch (v, filter_expression));
var removed = input.Where ((v) => !filtered.Contains (v));
if (removed.Any ()) {
Console.WriteLine ($"Filtered out {removed.Count ()} {name}s for {repo}/{proj}: {string.Join (", ", removed)}");
return filtered;
}
return input;
}

// Create the test variations for each project.
foreach (var proj in executable_projects) {
if (!samples.TryGetValue (proj.RelativePath, out var sample))
samples [proj.RelativePath] = sample = new SampleTest ();
sample.Project = proj;
string [] platforms;
IEnumerable<string> platforms;
switch (proj.Platform) {
case TestPlatform.iOS:
case TestPlatform.tvOS:
Expand All @@ -204,12 +222,14 @@ protected static IEnumerable<SampleTestData> GetSampleTestData (Dictionary<strin
default:
throw new NotImplementedException (proj.Platform.ToString ());
}
foreach (var platform in platforms) {

foreach (var platform in filter ("platform", proj.Title, platforms, platform_filter)) {
var configs = new List<string> ();
configs.AddRange (sample.DebugConfigurations ?? defaultDebugConfigurations);
configs.AddRange (sample.ReleaseConfigurations ?? defaultReleaseConfigurations);
foreach (var config in configs)
foreach (var config in filter ("config", proj.Title, configs, config_filter)) {
yield return new SampleTestData { SampleTest = sample, Configuration = config, Platform = platform };
}
}
}
}
Expand Down

0 comments on commit 77f905e

Please sign in to comment.