Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 34 additions & 57 deletions tests/xharness/Jenkins/Jenkins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Xharness.TestTasks;

namespace Xharness.Jenkins {
public class Jenkins
public class Jenkins : IResourceManager
{
readonly ISimulatorLoader simulators;
readonly IHardwareDeviceLoader devices;
Expand Down Expand Up @@ -80,8 +80,8 @@ public ILogs Logs {
List<AppleTestTask> Tasks = new List<AppleTestTask> ();
Dictionary<string, MakeTask> DependencyTasks = new Dictionary<string, MakeTask> ();

internal static Resource DesktopResource = new Resource ("Desktop", Environment.ProcessorCount);
internal static Resource NugetResource = new Resource ("Nuget", 1); // nuget is not parallel-safe :(
public Resource DesktopResource { get; } = new Resource ("Desktop", Environment.ProcessorCount);
public Resource NugetResource { get; } = new Resource ("Nuget", 1); // nuget is not parallel-safe :(

static Dictionary<string, Resource> device_resources = new Dictionary<string, Resource> ();
internal static Resources GetDeviceResources (IEnumerable<IHardwareDevice> devices)
Expand Down Expand Up @@ -481,9 +481,7 @@ IEnumerable<T> CreateTestVariations<T> (IEnumerable<T> tests, Func<MSBuildTask,
clone.Xml.Save (clone.Path);
});

var build = new MSBuildTask (processManager) {
Jenkins = this,
TestProject = clone,
var build = new MSBuildTask (jenkins: this, testProject: clone, processManager: processManager) {
ProjectConfiguration = configuration,
ProjectPlatform = task.ProjectPlatform,
Platform = task.Platform,
Expand Down Expand Up @@ -530,8 +528,7 @@ async Task<IEnumerable<AppleTestTask>> CreateRunSimulatorTasksAsync ()
configurations = new string [] { "Debug" };
foreach (var config in configurations) {
foreach (var pair in ps) {
var derived = new MSBuildTask (processManager) {
Jenkins = this,
var derived = new MSBuildTask (jenkins: this, testProject: project, processManager: processManager) {
ProjectConfiguration = config,
ProjectPlatform = "iPhoneSimulator",
Platform = pair.Item2,
Expand Down Expand Up @@ -561,8 +558,7 @@ async Task<IEnumerable<AppleTestTask>> CreateRunSimulatorTasksAsync ()

var rv = new List<AggregatedRunSimulatorTask> ();
foreach (var taskGroup in testVariations.GroupBy ((RunSimulatorTask task) => task.Device?.UDID ?? task.Candidates.ToString ())) {
rv.Add (new AggregatedRunSimulatorTask (taskGroup) {
Jenkins = this,
rv.Add (new AggregatedRunSimulatorTask (jenkins: this, tasks: taskGroup) {
TestName = $"Tests for {taskGroup.Key}",
});
}
Expand All @@ -584,8 +580,7 @@ Task<IEnumerable<AppleTestTask>> CreateRunDeviceTasksAsync ()

projectTasks.Clear ();
if (!project.SkipiOSVariation) {
var build64 = new MSBuildTask (processManager) {
Jenkins = this,
var build64 = new MSBuildTask (jenkins: this, testProject: project, processManager: processManager) {
ProjectConfiguration = "Debug64",
ProjectPlatform = "iPhone",
Platform = TestPlatform.iOS_Unified64,
Expand All @@ -594,8 +589,7 @@ Task<IEnumerable<AppleTestTask>> CreateRunDeviceTasksAsync ()
build64.CloneTestProject (project);
projectTasks.Add (new RunDeviceTask (devices, build64, processManager, devices.Connected64BitIOS.Where (d => project.IsSupported (d.DevicePlatform, d.ProductVersion))) { Ignored = !IncludeiOS64 });

var build32 = new MSBuildTask (processManager) {
Jenkins = this,
var build32 = new MSBuildTask (jenkins: this, testProject: project, processManager: processManager) {
ProjectConfiguration = project.Name != "dont link" ? "Debug32" : "Release32",
ProjectPlatform = "iPhone",
Platform = TestPlatform.iOS_Unified32,
Expand All @@ -605,8 +599,7 @@ Task<IEnumerable<AppleTestTask>> CreateRunDeviceTasksAsync ()
projectTasks.Add (new RunDeviceTask (devices, build32, processManager, devices.Connected32BitIOS.Where (d => project.IsSupported (d.DevicePlatform, d.ProductVersion))) { Ignored = !IncludeiOS32 });

var todayProject = project.AsTodayExtensionProject ();
var buildToday = new MSBuildTask (processManager) {
Jenkins = this,
var buildToday = new MSBuildTask (jenkins: this, testProject: todayProject, processManager: processManager) {
ProjectConfiguration = "Debug64",
ProjectPlatform = "iPhone",
Platform = TestPlatform.iOS_TodayExtension64,
Expand All @@ -618,8 +611,7 @@ Task<IEnumerable<AppleTestTask>> CreateRunDeviceTasksAsync ()

if (!project.SkiptvOSVariation) {
var tvOSProject = project.AsTvOSProject ();
var buildTV = new MSBuildTask (processManager) {
Jenkins = this,
var buildTV = new MSBuildTask (jenkins: this, testProject: tvOSProject, processManager: processManager) {
ProjectConfiguration = "Debug",
ProjectPlatform = "iPhone",
Platform = TestPlatform.tvOS,
Expand All @@ -632,8 +624,7 @@ Task<IEnumerable<AppleTestTask>> CreateRunDeviceTasksAsync ()
if (!project.SkipwatchOSVariation) {
var watchOSProject = project.AsWatchOSProject ();
if (!project.SkipwatchOS32Variation) {
var buildWatch32 = new MSBuildTask (processManager) {
Jenkins = this,
var buildWatch32 = new MSBuildTask (jenkins: this, testProject: watchOSProject, processManager: processManager) {
ProjectConfiguration = "Debug32",
ProjectPlatform = "iPhone",
Platform = TestPlatform.watchOS_32,
Expand All @@ -644,8 +635,7 @@ Task<IEnumerable<AppleTestTask>> CreateRunDeviceTasksAsync ()
}

if (!project.SkipwatchOSARM64_32Variation) {
var buildWatch64_32 = new MSBuildTask (processManager) {
Jenkins = this,
var buildWatch64_32 = new MSBuildTask (jenkins: this, testProject: watchOSProject, processManager: processManager) {
ProjectConfiguration = "Release64_32", // We don't support Debug for ARM64_32 yet.
ProjectPlatform = "iPhone",
Platform = TestPlatform.watchOS_64_32,
Expand Down Expand Up @@ -940,10 +930,9 @@ Task PopulateTasksAsync ()

var crashReportSnapshotFactory = new CrashSnapshotReporterFactory (processManager);

var buildiOSMSBuild_net461 = new MSBuildTask (processManager)
var net461Project = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj")));
var buildiOSMSBuild_net461 = new MSBuildTask (jenkins: this, testProject: net461Project, processManager: processManager)
{
Jenkins = this,
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj"))),
SpecifyPlatform = false,
SpecifyConfiguration = true,
ProjectConfiguration = "Debug-net461",
Expand All @@ -954,7 +943,7 @@ Task PopulateTasksAsync ()
var nunitExecutioniOSMSBuild_net461 = new NUnitExecuteTask (buildiOSMSBuild_net461, processManager)
{
TestLibrary = Path.Combine (Harness.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "bin", "Debug-net461", "net461", "Xamarin.iOS.Tasks.Tests.dll"),
TestProject = buildiOSMSBuild_net461.TestProject,
TestProject = net461Project,
ProjectConfiguration = "Debug-net461",
Platform = TestPlatform.iOS,
TestName = "MSBuild tests",
Expand All @@ -965,9 +954,8 @@ Task PopulateTasksAsync ()
};
Tasks.Add (nunitExecutioniOSMSBuild_net461);

var buildiOSMSBuild_netstandard2 = new MSBuildTask (processManager) {
Jenkins = this,
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj"))),
var netstandard2Project = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj")));
var buildiOSMSBuild_netstandard2 = new MSBuildTask (jenkins: this, testProject: netstandard2Project, processManager: processManager) {
SpecifyPlatform = false,
SpecifyConfiguration = true,
ProjectConfiguration = "Debug-netstandard2.0",
Expand All @@ -977,7 +965,7 @@ Task PopulateTasksAsync ()
};
var nunitExecutioniOSMSBuild_netstandard2 = new NUnitExecuteTask (buildiOSMSBuild_netstandard2, processManager) {
TestLibrary = Path.Combine (Harness.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "bin", "Debug-netstandard2.0", "net461", "Xamarin.iOS.Tasks.Tests.dll"),
TestProject = buildiOSMSBuild_netstandard2.TestProject,
TestProject = netstandard2Project,
ProjectConfiguration = "Debug-netstandard2.0",
Platform = TestPlatform.iOS,
TestName = "MSBuild tests",
Expand All @@ -988,10 +976,9 @@ Task PopulateTasksAsync ()
};
Tasks.Add (nunitExecutioniOSMSBuild_netstandard2);

var buildInstallSources = new MSBuildTask (processManager)
var installSourcesProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "InstallSourcesTests.csproj")));
var buildInstallSources = new MSBuildTask (jenkins: this, testProject: installSourcesProject, processManager: processManager)
{
Jenkins = this,
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "InstallSourcesTests.csproj"))),
SpecifyPlatform = false,
SpecifyConfiguration = false,
Platform = TestPlatform.iOS,
Expand All @@ -1000,7 +987,7 @@ Task PopulateTasksAsync ()
var nunitExecutionInstallSource = new NUnitExecuteTask (buildInstallSources, processManager)
{
TestLibrary = Path.Combine (Harness.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "bin", "Release", "InstallSourcesTests.dll"),
TestProject = buildInstallSources.TestProject,
TestProject = installSourcesProject,
Platform = TestPlatform.iOS,
TestName = "Install Sources tests",
Mode = "iOS",
Expand Down Expand Up @@ -1039,10 +1026,9 @@ Task PopulateTasksAsync ()
throw new NotImplementedException (project.TargetFrameworkFlavors.ToString ());
}
foreach (var config in configurations) {
MSBuildTask build = new MSBuildTask (processManager);
MSBuildTask build = new MSBuildTask (jenkins: this, testProject: project, processManager: processManager);
build.Platform = platform;
build.CloneTestProject (project);
build.Jenkins = this;
build.SolutionPath = project.SolutionPath;
build.ProjectConfiguration = config;
build.ProjectPlatform = project.Platform;
Expand Down Expand Up @@ -1082,9 +1068,8 @@ Task PopulateTasksAsync ()
}
}

var buildMTouch = new MakeTask (processManager)
var buildMTouch = new MakeTask (jenkins: this, processManager: processManager)
{
Jenkins = this,
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "mtouch", "mtouch.sln"))),
SpecifyPlatform = false,
SpecifyConfiguration = false,
Expand All @@ -1104,8 +1089,7 @@ Task PopulateTasksAsync ()
};
Tasks.Add (nunitExecutionMTouch);

var buildGenerator = new MakeTask (processManager) {
Jenkins = this,
var buildGenerator = new MakeTask (jenkins: this, processManager: processManager) {
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "..", "src", "generator.sln"))),
SpecifyPlatform = false,
SpecifyConfiguration = false,
Expand All @@ -1124,25 +1108,24 @@ Task PopulateTasksAsync ()
};
Tasks.Add (runGenerator);

var buildDotNetGenerator = new DotNetBuildTask (processManager) {
Jenkins = this,
var buildDotNetGeneratorProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "bgen", "bgen-tests.csproj")));
var buildDotNetGenerator = new DotNetBuildTask (jenkins: this, testProject: buildDotNetGeneratorProject, processManager: processManager) {
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "bgen", "bgen-tests.csproj"))),
SpecifyPlatform = false,
SpecifyConfiguration = false,
Platform = TestPlatform.iOS,
};
var runDotNetGenerator = new DotNetTestTask (buildDotNetGenerator, processManager) {
TestProject = buildDotNetGenerator.TestProject,
TestProject = buildDotNetGeneratorProject,
Platform = TestPlatform.iOS,
TestName = "Generator tests",
Mode = ".NET",
Ignored = !IncludeBtouch,
};
Tasks.Add (runDotNetGenerator);

var run_mmp = new MakeTask (processManager)
var run_mmp = new MakeTask (jenkins: this, processManager: processManager)
{
Jenkins = this,
Platform = TestPlatform.Mac,
TestName = "MMP Regression Tests",
Target = "all", // -j" + Environment.ProcessorCount,
Expand All @@ -1159,9 +1142,8 @@ Task PopulateTasksAsync ()
run_mmp.Environment.Add ("BUILD_REVISION", "jenkins"); // This will print "@MonkeyWrench: AddFile: <log path>" lines, which we can use to get the log filenames.
Tasks.Add (run_mmp);

var runMacBindingProject = new MakeTask (processManager)
var runMacBindingProject = new MakeTask (jenkins: this, processManager: processManager)
{
Jenkins = this,
Platform = TestPlatform.Mac,
TestName = "Mac Binding Projects",
Target = "all",
Expand All @@ -1171,8 +1153,7 @@ Task PopulateTasksAsync ()
};
Tasks.Add (runMacBindingProject);

var buildXtroTests = new MakeTask (processManager) {
Jenkins = this,
var buildXtroTests = new MakeTask (jenkins: this, processManager: processManager) {
Platform = TestPlatform.All,
TestName = "Xtro",
Target = "wrench",
Expand All @@ -1181,16 +1162,14 @@ Task PopulateTasksAsync ()
Timeout = TimeSpan.FromMinutes (15),
};
var runXtroReporter = new RunXtroTask (buildXtroTests, processManager, crashReportSnapshotFactory) {
Jenkins = this,
Platform = TestPlatform.Mac,
TestName = buildXtroTests.TestName,
Ignored = buildXtroTests.Ignored,
WorkingDirectory = buildXtroTests.WorkingDirectory,
};
Tasks.Add (runXtroReporter);

var buildCecilTests = new MakeTask (processManager) {
Jenkins = this,
var buildCecilTests = new MakeTask (jenkins: this, processManager: processManager) {
Platform = TestPlatform.All,
TestName = "Cecil",
Target = "build",
Expand All @@ -1209,8 +1188,7 @@ Task PopulateTasksAsync ()
};
Tasks.Add (runCecilTests);

var runDocsTests = new MakeTask (processManager) {
Jenkins = this,
var runDocsTests = new MakeTask (jenkins: this, processManager: processManager) {
Platform = TestPlatform.All,
TestName = "Documentation",
Target = "wrench-docs",
Expand All @@ -1220,9 +1198,8 @@ Task PopulateTasksAsync ()
};
Tasks.Add (runDocsTests);

var buildSampleTests = new MSBuildTask (processManager) {
Jenkins = this,
TestProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "sampletester", "sampletester.sln"))),
var buildSampleTestsProject = new TestProject (Path.GetFullPath (Path.Combine (Harness.RootDirectory, "sampletester", "sampletester.sln")));
var buildSampleTests = new MSBuildTask (jenkins: this, testProject: buildSampleTestsProject, processManager: processManager) {
SpecifyPlatform = false,
Platform = TestPlatform.All,
ProjectConfiguration = "Debug",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AggregatedRunSimulatorTask : AppleTestTask
Stopwatch run_timer = new Stopwatch ();
public TimeSpan RunDuration { get { return run_timer.Elapsed; } }

public AggregatedRunSimulatorTask (IEnumerable<RunSimulatorTask> tasks)
public AggregatedRunSimulatorTask (Jenkins jenkins, IEnumerable<RunSimulatorTask> tasks) : base (jenkins)
{
this.Tasks = tasks;
}
Expand Down
13 changes: 9 additions & 4 deletions tests/xharness/Jenkins/TestTasks/AppleTestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
namespace Xharness.Jenkins.TestTasks {
public abstract class AppleTestTask : Xharness.TestTasks.TestTasks
{
public Jenkins Jenkins;
public Jenkins Jenkins { get; private set; }
public Harness Harness { get { return Jenkins.Harness; } }

public override IResourceManager ResourceManager => Jenkins;

public override string LogDirectory {
get {
Expand All @@ -20,11 +21,16 @@ public override string LogDirectory {
}
}

public AppleTestTask (Jenkins jenkins) : base ()
{
Jenkins = jenkins ?? throw new ArgumentNullException (nameof (jenkins));
}

public override void GenerateReport () => Jenkins.GenerateReport ();

protected override void WriteLineToRunnerLog (string message) => Harness.HarnessLog.WriteLine (message);

protected override void SetEnvironmentVariables (Process process)
public override void SetEnvironmentVariables (Process process)
{
var xcodeRoot = Harness.XcodeRoot;

Expand Down Expand Up @@ -77,8 +83,7 @@ protected override void SetEnvironmentVariables (Process process)
}
}


protected override void LogEvent (ILog log, string text, params object [] args)
public override void LogEvent (ILog log, string text, params object [] args)
{
base.LogEvent (log, text, args);
Jenkins.MainLog.WriteLine (text, args);
Expand Down
Loading