IEnumerable <MacExecuteTask> CreateMacExecuteTask(MacTestProject project, MSBuildTask build, bool ignored) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (build == null) { throw new ArgumentNullException(nameof(build)); } var exec = new MacExecuteTask(jenkins, build, processManager, crashReportSnapshotFactory) { Ignored = ignored, BCLTest = project.IsBclTest(), TestName = project.Name, IsUnitTest = true, }; return(testVariationsFactory.CreateTestVariations(new [] { exec }, (buildTask, test, candidates) => new MacExecuteTask(jenkins, buildTask, processManager, crashReportSnapshotFactory) { IsUnitTest = true })); }
public void UpdateProject(MSBuildProject project) { if (importToRemove == null) { return; } MSBuildTarget nugetImportTarget = FindNuGetImportTarget(project); if (nugetImportTarget == null) { return; } MSBuildTask msbuildTask = FindErrorTaskForImport(nugetImportTarget, importToRemove); if (msbuildTask == null) { return; } nugetImportTarget.RemoveTask(msbuildTask); if (nugetImportTarget.Tasks.Count() == 0) { project.Remove(nugetImportTarget); } }
public IEnumerator <RunTestTask> GetEnumerator() { foreach (var project in jenkins.Harness.MacTestProjects) { bool ignored = !jenkins.IncludeMac; if (project.Ignore == true) { ignored = true; } if (!jenkins.IncludeMmpTest && project.Path.Contains("mmptest")) { ignored = true; } if (!jenkins.IsIncluded(project)) { ignored = true; } var configurations = project.Configurations; if (configurations == null) { configurations = new string [] { "Debug" } } ; TestPlatform platform = project.TargetFrameworkFlavors.ToTestPlatform(); foreach (var config in configurations) { MSBuildTask build = new MSBuildTask(jenkins: jenkins, testProject: project, processManager: processManager); build.Platform = platform; build.CloneTestProject(jenkins.MainLog, processManager, project, HarnessConfiguration.RootDirectory); build.ProjectConfiguration = config; build.ProjectPlatform = project.Platform; build.SpecifyPlatform = false; build.SpecifyConfiguration = build.ProjectConfiguration != "Debug"; build.Dependency = project.Dependency; var ignored_main = ignored; var execs = project.IsNUnitProject ? (IEnumerable <RunTestTask>) new [] { CreateNUnitTask(project, build, ignored_main) } : CreateMacExecuteTask(project, build, ignored_main); foreach (var e in execs) { e.Variation = string.IsNullOrEmpty(e.Variation) ? config : e.Variation; yield return(e); } } } } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }
public void TestGetTool_35File_20Tool() { var task = new MSBuildTask("test", Tool.Tool20Version, "test", true); var mock = new Mock <IToolPathValidator>(); // only .NET 2 is installed. mock.Setup(validator => validator.Validate(DotNet20)).Returns(true); mock.Setup(validator => validator.Validate(DotNet35)).Returns(false); mock.Setup(validator => validator.Validate(DotNet40)).Returns(false); mock.Setup(validator => validator.Validate(DotNet120)).Returns(false); task.Validator = mock.Object; Assert.AreEqual(null, task.FindMSBuildPath(Tool.Tool35Version)); }
public void TestGetTool_120File_20_35_40_120Tool() { var task = new MSBuildTask("test", Tool.Tool20Version, "test", true); var mock = new Mock <IToolPathValidator>(); // .NET 3.5 and 4/4.5 is installed. mock.Setup(validator => validator.Validate(DotNet20)).Returns(true); mock.Setup(validator => validator.Validate(DotNet35)).Returns(true); mock.Setup(validator => validator.Validate(DotNet40)).Returns(true); mock.Setup(validator => validator.Validate(DotNet120)).Returns(true); task.Validator = mock.Object; Assert.AreEqual(DotNet120.Path, task.FindMSBuildPath(Tool.Tool120Version)); }
public void TestGetTool_20File_20Tool() { var task = new MSBuildTask("test", ToolElement.Tool20Version, "test", true); var mock = new Mock<IToolPathValidator>(); // only .NET 2 is installed. mock.Setup(validator => validator.Validate(DotNet20)).Returns(true); mock.Setup(validator => validator.Validate(DotNet35)).Returns(false); mock.Setup(validator => validator.Validate(DotNet40)).Returns(false); mock.Setup(validator => validator.Validate(DotNet120)).Returns(false); task.Validator = mock.Object; Assert.AreEqual(DotNet20.Path, task.FindMSBuildPath(ToolElement.Tool20Version)); }
NUnitExecuteTask CreateNUnitTask(MacTestProject project, MSBuildTask build, bool ignored) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (build == null) { throw new ArgumentNullException(nameof(build)); } var dll = Path.Combine(Path.GetDirectoryName(build.TestProject.Path), project.Xml.GetOutputAssemblyPath(build.ProjectPlatform, build.ProjectConfiguration).Replace('\\', '/')); return(new NUnitExecuteTask(jenkins, build, processManager) { Ignored = ignored, TestLibrary = dll, TestProject = project, Platform = build.Platform, TestName = project.Name, Timeout = TimeSpan.FromMinutes(120), Mode = "macOS", }); }
public Task <IEnumerable <ITestTask> > CreateAsync(Jenkins jenkins, IProcessManager processManager, TestVariationsFactory testVariationsFactory) { var rv = new List <RunDeviceTask> (); var projectTasks = new List <RunDeviceTask> (); foreach (var project in jenkins.Harness.IOSTestProjects) { if (!project.IsExecutableProject) { continue; } if (project.SkipDeviceVariations) { continue; } bool ignored = !jenkins.IncludeDevice; if (!jenkins.IsIncluded(project)) { ignored = true; } projectTasks.Clear(); bool createiOS; bool createTodayExtension; bool createtvOS; bool createwatchOS; if (project.GenerateVariations) { createiOS = !project.SkipiOSVariation; createTodayExtension = !project.SkipTodayExtensionVariation; createtvOS = !project.SkiptvOSVariation; createwatchOS = !project.SkipwatchOSVariation; } else { createiOS = project.TestPlatform == TestPlatform.iOS_Unified; createTodayExtension = project.TestPlatform == TestPlatform.iOS_TodayExtension64; createtvOS = project.TestPlatform == TestPlatform.tvOS; createwatchOS = project.TestPlatform == TestPlatform.watchOS; } if (createiOS) { var build64 = new MSBuildTask(jenkins: jenkins, testProject: project, processManager: processManager) { ProjectConfiguration = "Debug64", ProjectPlatform = "iPhone", Platform = TestPlatform.iOS_Unified64, TestName = project.Name, }; build64.CloneTestProject(jenkins.MainLog, processManager, project); projectTasks.Add(new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: build64, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: jenkins.Devices.Connected64BitIOS.Where(d => project.IsSupported(d.DevicePlatform, d.ProductVersion))) { Ignored = !jenkins.IncludeiOS64 }); var build32 = new MSBuildTask(jenkins: jenkins, testProject: project, processManager: processManager) { ProjectConfiguration = project.Name != "dont link" ? "Debug32" : "Release32", ProjectPlatform = "iPhone", Platform = TestPlatform.iOS_Unified32, TestName = project.Name, }; build32.CloneTestProject(jenkins.MainLog, processManager, project); projectTasks.Add(new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: build32, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: jenkins.Devices.Connected32BitIOS.Where(d => project.IsSupported(d.DevicePlatform, d.ProductVersion))) { Ignored = !jenkins.IncludeiOS32 }); if (createTodayExtension) { var todayProject = project.GenerateVariations ? project.AsTodayExtensionProject() : project; var buildToday = new MSBuildTask(jenkins: jenkins, testProject: todayProject, processManager: processManager) { ProjectConfiguration = "Debug64", ProjectPlatform = "iPhone", Platform = TestPlatform.iOS_TodayExtension64, TestName = project.Name, }; buildToday.CloneTestProject(jenkins.MainLog, processManager, todayProject); projectTasks.Add(new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: buildToday, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: jenkins.Devices.Connected64BitIOS.Where(d => project.IsSupported(d.DevicePlatform, d.ProductVersion))) { Ignored = !jenkins.IncludeiOSExtensions, BuildOnly = jenkins.ForceExtensionBuildOnly }); } } if (createtvOS) { var tvOSProject = project.GenerateVariations ? project.AsTvOSProject() : project; var buildTV = new MSBuildTask(jenkins: jenkins, testProject: tvOSProject, processManager: processManager) { ProjectConfiguration = "Debug", ProjectPlatform = "iPhone", Platform = TestPlatform.tvOS, TestName = project.Name, }; buildTV.CloneTestProject(jenkins.MainLog, processManager, tvOSProject); projectTasks.Add(new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: buildTV, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: jenkins.Devices.ConnectedTV.Where(d => project.IsSupported(d.DevicePlatform, d.ProductVersion))) { Ignored = !jenkins.IncludetvOS }); } if (createwatchOS) { var watchOSProject = project.GenerateVariations ? project.AsWatchOSProject() : project; if (!project.SkipwatchOS32Variation) { var buildWatch32 = new MSBuildTask(jenkins: jenkins, testProject: watchOSProject, processManager: processManager) { ProjectConfiguration = "Debug32", ProjectPlatform = "iPhone", Platform = TestPlatform.watchOS_32, TestName = project.Name, }; buildWatch32.CloneTestProject(jenkins.MainLog, processManager, watchOSProject); projectTasks.Add(new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: buildWatch32, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: jenkins.Devices.ConnectedWatch) { Ignored = !jenkins.IncludewatchOS }); } if (!project.SkipwatchOSARM64_32Variation) { var buildWatch64_32 = new MSBuildTask(jenkins: jenkins, testProject: watchOSProject, processManager: processManager) { ProjectConfiguration = "Release64_32", // We don't support Debug for ARM64_32 yet. ProjectPlatform = "iPhone", Platform = TestPlatform.watchOS_64_32, TestName = project.Name, }; buildWatch64_32.CloneTestProject(jenkins.MainLog, processManager, watchOSProject); projectTasks.Add(new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: buildWatch64_32, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: jenkins.Devices.ConnectedWatch32_64.Where(d => project.IsSupported(d.DevicePlatform, d.ProductVersion))) { Ignored = !jenkins.IncludewatchOS }); } } foreach (var task in projectTasks) { task.TimeoutMultiplier = project.TimeoutMultiplier; task.BuildOnly |= project.BuildOnly; task.Ignored |= ignored; } rv.AddRange(projectTasks); } return(Task.FromResult <IEnumerable <ITestTask> > (testVariationsFactory.CreateTestVariations(rv, (buildTask, test, candidates) => new RunDeviceTask( jenkins: jenkins, devices: jenkins.Devices, buildTask: buildTask, processManager: processManager, tunnelBore: jenkins.TunnelBore, errorKnowledgeBase: jenkins.ErrorKnowledgeBase, useTcpTunnel: jenkins.Harness.UseTcpTunnel, candidates: candidates?.Cast <IHardwareDevice> () ?? test.Candidates)))); }
public IEnumerator <NUnitExecuteTask> GetEnumerator() { var netstandard2Project = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj"))); var buildiOSMSBuild = new MSBuildTask(jenkins: jenkins, testProject: netstandard2Project, processManager: processManager) { SpecifyPlatform = false, SpecifyConfiguration = true, ProjectConfiguration = "Debug", Platform = TestPlatform.iOS, SolutionPath = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "msbuild", "Xamarin.MacDev.Tasks.sln")), SupportsParallelExecution = false, }; var nunitExecutioniOSMSBuild = new NUnitExecuteTask(jenkins, buildiOSMSBuild, processManager) { TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "..", "msbuild", "tests", "Xamarin.iOS.Tasks.Tests", "bin", "Debug", "net461", "Xamarin.iOS.Tasks.Tests.dll"), TestProject = netstandard2Project, ProjectConfiguration = "Debug", Platform = TestPlatform.iOS, TestName = "MSBuild tests", Mode = "iOS", Timeout = TimeSpan.FromMinutes(60), Ignored = !jenkins.IncludeiOSMSBuild, SupportsParallelExecution = false, }; yield return(nunitExecutioniOSMSBuild); var installSourcesProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "InstallSourcesTests.csproj"))); var buildInstallSources = new MSBuildTask(jenkins: jenkins, testProject: installSourcesProject, processManager: processManager) { SpecifyPlatform = false, SpecifyConfiguration = false, Platform = TestPlatform.iOS, }; buildInstallSources.SolutionPath = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "tools", "install-source", "install-source.sln")); // this is required for nuget restore to be executed var nunitExecutionInstallSource = new NUnitExecuteTask(jenkins, buildInstallSources, processManager) { TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "..", "tools", "install-source", "InstallSourcesTests", "bin", "Release", "InstallSourcesTests.dll"), TestProject = installSourcesProject, Platform = TestPlatform.iOS, TestName = "Install Sources tests", Mode = "iOS", Timeout = TimeSpan.FromMinutes(60), Ignored = !jenkins.IncludeMac && !jenkins.IncludeSimulator, }; yield return(nunitExecutionInstallSource); var buildMTouch = new MakeTask(jenkins: jenkins, processManager: processManager) { TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "mtouch", "mtouch.sln"))), SpecifyPlatform = false, SpecifyConfiguration = false, Platform = TestPlatform.iOS, Target = "dependencies", WorkingDirectory = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "mtouch")), }; var nunitExecutionMTouch = new NUnitExecuteTask(jenkins, buildMTouch, processManager) { TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "mtouch", "bin", "Debug", "mtouch.dll"), TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "mtouch", "mtouch.csproj"))), Platform = TestPlatform.iOS, TestName = "MTouch tests", Timeout = TimeSpan.FromMinutes(180), Ignored = !jenkins.IncludeMtouch, InProcess = true, }; yield return(nunitExecutionMTouch); var buildGenerator = new MakeTask(jenkins: jenkins, processManager: processManager) { TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "..", "src", "generator.sln"))), SpecifyPlatform = false, SpecifyConfiguration = false, Platform = TestPlatform.iOS, Target = "build-unit-tests", WorkingDirectory = Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "generator")), }; var runGenerator = new NUnitExecuteTask(jenkins, buildGenerator, processManager) { TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "generator", "bin", "Debug", "generator-tests.dll"), TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "generator", "generator-tests.csproj"))), Platform = TestPlatform.iOS, TestName = "Generator tests", Mode = "NUnit", Timeout = TimeSpan.FromMinutes(10), Ignored = !jenkins.IncludeBtouch, }; yield return(runGenerator); var buildCecilTestsProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "cecil-tests", "cecil-tests.csproj"))); buildCecilTestsProject.RestoreNugetsInProject = true; var buildCecilTests = new MSBuildTask(jenkins: jenkins, testProject: buildCecilTestsProject, processManager: processManager) { SpecifyPlatform = false, Platform = TestPlatform.All, ProjectConfiguration = "Debug", Ignored = !jenkins.IncludeCecil, }; var runCecilTests = new NUnitExecuteTask(jenkins, buildCecilTests, processManager) { TestLibrary = Path.Combine(Path.GetDirectoryName(buildCecilTestsProject.Path), "bin", "Debug", "net472", "cecil-tests.dll"), TestProject = buildCecilTestsProject, Platform = TestPlatform.iOS, TestName = "Cecil-based tests", Timeout = TimeSpan.FromMinutes(5), Ignored = !jenkins.IncludeCecil, InProcess = true, }; yield return(runCecilTests); var buildSampleTestsProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "sampletester", "sampletester.csproj"))); var buildSampleTests = new MSBuildTask(jenkins: jenkins, testProject: buildSampleTestsProject, processManager: processManager) { SpecifyPlatform = false, Platform = TestPlatform.All, ProjectConfiguration = "Debug", }; var runSampleTests = new NUnitExecuteTask(jenkins, buildSampleTests, processManager) { TestLibrary = Path.Combine(HarnessConfiguration.RootDirectory, "sampletester", "bin", "Debug", "sampletester.dll"), TestProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "sampletester", "sampletester.csproj"))), Platform = TestPlatform.All, TestName = "Sample tests", Timeout = TimeSpan.FromDays(1), // These can take quite a while to execute. InProcess = true, Ignored = true, // Ignored by default, can be run manually. On CI will execute if the label 'run-sample-tests' is present on a PR (but in Azure Devops on a different bot). }; yield return(runSampleTests); }
Task PopulateTasksAsync() { // Missing: // api-diff testSelector.SelectTests(); DeviceLoader.LoadAllAsync().DoNotAwait(); var simTasksFactory = new RunSimulatorTasksFactory(); var loadsim = simTasksFactory.CreateAsync(this, processManager, testVariationsFactory) .ContinueWith((v) => { if (v.Status == TaskStatus.RanToCompletion) { Console.WriteLine("Simulator tasks created"); Tasks.AddRange(v.Result); } else { Console.WriteLine($"Failed to create simulator tasks: {v.Exception}"); } }); //Tasks.AddRange (await CreateRunSimulatorTasksAsync ()); var crashReportSnapshotFactory = new CrashSnapshotReporterFactory(processManager); // all factories are enumerators \o/ var testFactories = new IEnumerable <AppleTestTask> [] { new MacTestTasksEnumerable(this, processManager, crashReportSnapshotFactory, testVariationsFactory), new NUnitTestTasksEnumerable(this, processManager), new MakeTestTaskEnumerable(this, processManager) }; // add all tests defined by the factory foreach (var f in testFactories) { Tasks.AddRange(f); } // individual special tasks var buildXtroTests = new MakeTask(jenkins: this, processManager: processManager) { Platform = TestPlatform.All, TestName = "Xtro", Target = "wrench", WorkingDirectory = Path.Combine(HarnessConfiguration.RootDirectory, "xtro-sharpie"), Ignored = !IncludeXtro, Timeout = TimeSpan.FromMinutes(15), }; var runXtroReporter = new RunXtroTask(this, buildXtroTests, processManager, crashReportSnapshotFactory) { Platform = TestPlatform.Mac, TestName = buildXtroTests.TestName, Ignored = buildXtroTests.Ignored, WorkingDirectory = buildXtroTests.WorkingDirectory, }; Tasks.Add(runXtroReporter); var buildDotNetGeneratorProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "bgen", "bgen-tests.csproj"))) { IsDotNetProject = true, }; var buildDotNetGenerator = new MSBuildTask(jenkins: this, testProject: buildDotNetGeneratorProject, processManager: processManager) { TestProject = buildDotNetGeneratorProject, SpecifyPlatform = false, SpecifyConfiguration = false, Platform = TestPlatform.iOS, }; var runDotNetGenerator = new DotNetTestTask(this, buildDotNetGenerator, processManager) { TestProject = buildDotNetGeneratorProject, Platform = TestPlatform.iOS, TestName = "Generator tests", Mode = ".NET", Ignored = !IncludeBtouch, }; Tasks.Add(runDotNetGenerator); var buildDotNetTestsProject = new TestProject(Path.GetFullPath(Path.Combine(HarnessConfiguration.RootDirectory, "dotnet", "UnitTests", "DotNetUnitTests.csproj"))) { IsDotNetProject = true, }; var buildDotNetTests = new MSBuildTask(this, testProject: buildDotNetTestsProject, processManager: processManager) { SpecifyPlatform = false, Platform = TestPlatform.All, ProjectConfiguration = "Debug", Ignored = !IncludeDotNet, }; var runDotNetTests = new DotNetTestTask(this, buildDotNetTests, processManager) { TestProject = buildDotNetTestsProject, Platform = TestPlatform.All, TestName = "DotNet tests", Timeout = TimeSpan.FromMinutes(90), Ignored = !IncludeDotNet, }; Tasks.Add(runDotNetTests); var deviceTestFactory = new RunDeviceTasksFactory(); var loaddev = deviceTestFactory.CreateAsync(this, processManager, testVariationsFactory).ContinueWith((v) => { Console.WriteLine("Got device tasks completed"); Tasks.AddRange(v.Result); }); return(Task.WhenAll(loadsim, loaddev)); }
IEnumerable <ITestTask> CreateMacCatalystTests(CrashSnapshotReporterFactory crashSnapshotReporterFactory) { var projectTasks = new List <RunTestTask> (); foreach (var project in Harness.IOSTestProjects) { if (!project.IsExecutableProject) { continue; } if (project.SkipMacCatalystVariation) { continue; } if (!project.GenerateVariations) { continue; } var ignored = project.Ignore ?? !IncludeMacCatalyst; if (!IsIncluded(project)) { ignored = true; } var macCatalystProject = project.GenerateVariations ? project.AsMacCatalystProject() : project; var build = new MSBuildTask(jenkins: this, testProject: macCatalystProject, processManager: processManager) { ProjectConfiguration = "Debug", ProjectPlatform = "iPhoneSimulator", Platform = TestPlatform.MacCatalyst, TestName = project.Name, }; build.CloneTestProject(MainLog, processManager, macCatalystProject, HarnessConfiguration.RootDirectory); RunTestTask task; if (project.IsNUnitProject) { var dll = Path.Combine(Path.GetDirectoryName(build.TestProject.Path), project.Xml.GetOutputAssemblyPath(build.ProjectPlatform, build.ProjectConfiguration).Replace('\\', '/')); task = new NUnitExecuteTask(this, build, processManager) { TestLibrary = dll, Mode = "MacCatalyst", }; } else { task = new MacExecuteTask(this, build, processManager, crashSnapshotReporterFactory) { IsUnitTest = true, }; } task.Ignored = ignored; task.Platform = build.Platform; task.TestName = project.Name; task.Timeout = TimeSpan.FromMinutes(120); task.Variation = task.ProjectConfiguration; if (project.IsDotNetProject) { task.Variation += " [dotnet]"; } projectTasks.Add(task); } return(projectTasks); }
public async Task <IEnumerable <ITestTask> > CreateAsync(Jenkins jenkins, IMlaunchProcessManager processManager, TestVariationsFactory testVariationsFactory) { var runSimulatorTasks = new List <RunSimulatorTask> (); foreach (var project in jenkins.Harness.IOSTestProjects) { if (!project.IsExecutableProject) { continue; } bool ignored = project.Ignore ?? !jenkins.IncludeSimulator; if (!jenkins.IsIncluded(project)) { ignored = true; } var ps = new List <Tuple <TestProject, TestPlatform, bool> > (); if (!project.GenerateVariations) { ps.Add(new Tuple <TestProject, TestPlatform, bool> (project, project.TestPlatform, ignored)); } else { if (!project.SkipiOSVariation) { ps.Add(new Tuple <TestProject, TestPlatform, bool> (project, TestPlatform.iOS_Unified, ignored)); } if (project.MonoNativeInfo != null) { ps.Add(new Tuple <TestProject, TestPlatform, bool> (project, TestPlatform.iOS_TodayExtension64, ignored)); } if (!project.SkiptvOSVariation) { ps.Add(new Tuple <TestProject, TestPlatform, bool> (project.AsTvOSProject(), TestPlatform.tvOS, ignored)); } if (!project.SkipwatchOSVariation) { ps.Add(new Tuple <TestProject, TestPlatform, bool> (project.AsWatchOSProject(), TestPlatform.watchOS, ignored)); } } var configurations = project.Configurations; if (configurations == null) { configurations = new string [] { "Debug" } } ; foreach (var config in configurations) { foreach (var pair in ps) { var configIgnored = pair.Item3; var testPlatform = pair.Item2; switch (testPlatform) { case TestPlatform.iOS_Unified: case TestPlatform.iOS_TodayExtension64: configIgnored |= !jenkins.IncludeiOS64; break; case TestPlatform.tvOS: configIgnored |= !jenkins.IncludetvOS; break; case TestPlatform.watchOS: configIgnored |= !jenkins.IncludewatchOS; break; default: Console.WriteLine("Unknown test platform for ignore check: {0}", testPlatform); break; } configIgnored |= project.IsDotNetProject && !jenkins.IncludeDotNet; var derived = new MSBuildTask(jenkins: jenkins, testProject: project, processManager: processManager); derived.ProjectConfiguration = config; derived.ProjectPlatform = "iPhoneSimulator"; derived.Platform = testPlatform; derived.Ignored = configIgnored; derived.TestName = project.Name; derived.Dependency = project.Dependency; derived.CloneTestProject(jenkins.MainLog, processManager, pair.Item1, HarnessConfiguration.RootDirectory); var simTasks = CreateAsync(jenkins, processManager, derived); runSimulatorTasks.AddRange(simTasks); foreach (var task in simTasks) { if (configurations.Length > 1) { task.Variation = config; } task.TimeoutMultiplier = project.TimeoutMultiplier; } } } } var testVariations = testVariationsFactory.CreateTestVariations(runSimulatorTasks, (buildTask, test, candidates) => new RunSimulatorTask( jenkins: jenkins, simulators: jenkins.Simulators, buildTask: buildTask, processManager: processManager, candidates: candidates?.Cast <SimulatorDevice> () ?? test.Candidates)).ToList(); if (jenkins.IsServerMode) { return(testVariations); } foreach (var tv in testVariations) { if (!tv.Ignored) { await tv.FindSimulatorAsync(); } } var rv = new List <AggregatedRunSimulatorTask> (); foreach (var taskGroup in testVariations.GroupBy((RunSimulatorTask task) => task.Device?.UDID ?? task.Candidates.ToString())) { rv.Add(new AggregatedRunSimulatorTask(jenkins: jenkins, tasks: taskGroup) { TestName = $"Tests for {taskGroup.Key}", }); } return(rv); } IEnumerable <RunSimulatorTask> CreateAsync(Jenkins jenkins, IMlaunchProcessManager processManager, MSBuildTask buildTask) { var runtasks = new List <RunSimulatorTask> (); TestTarget [] targets = buildTask.Platform.GetAppRunnerTargets(); TestPlatform [] platforms; bool [] ignored; switch (buildTask.Platform) { case TestPlatform.tvOS: platforms = new TestPlatform [] { TestPlatform.tvOS }; ignored = new [] { false }; break; case TestPlatform.watchOS: platforms = new TestPlatform [] { TestPlatform.watchOS_32 }; ignored = new [] { false }; break; case TestPlatform.iOS_Unified: platforms = new TestPlatform [] { TestPlatform.iOS_Unified64 }; ignored = new [] { false }; break; case TestPlatform.iOS_TodayExtension64: platforms = new TestPlatform [] { TestPlatform.iOS_TodayExtension64 }; ignored = new [] { false }; break; default: throw new NotImplementedException(); } for (int i = 0; i < targets.Length; i++) { var sims = jenkins.Simulators.SelectDevices(targets [i], jenkins.SimulatorLoadLog, false); runtasks.Add(new RunSimulatorTask( jenkins: jenkins, simulators: jenkins.Simulators, buildTask: buildTask, processManager: processManager, candidates: sims) { Platform = platforms [i], Ignored = ignored [i] || buildTask.Ignored }); } return(runtasks); } }
public IEnumerable <T> CreateTestVariations <T> (IEnumerable <T> tests, Func <MSBuildTask, T, IEnumerable <IDevice>, T> creator) where T : RunTestTask { foreach (var task in tests) { if (string.IsNullOrEmpty(task.Variation)) { task.Variation = task.ProjectConfiguration.Contains("Debug") ? "Debug" : "Release"; } if (task.TestProject.IsDotNetProject) { task.Variation += " [dotnet]"; } } var rv = new List <T> (tests); foreach (var task in tests.ToArray()) { 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 undefines = test_data.Undefines; var ignored = test_data.Ignored; var known_failure = test_data.KnownFailure; var candidates = test_data.Candidates; var use_mono_runtime = test_data.UseMonoRuntime; var xammac_arch = test_data.XamMacArch; var runtime_identifer = test_data.RuntimeIdentifier; var use_llvm = test_data.UseLlvm; if (task.TestProject.IsDotNetProject) { variation += " [dotnet]"; } if (known_failure is not null) { ignored = true; } var clone = task.TestProject.Clone(); var clone_task = Task.Run(async() => { await task.BuildTask.InitialTask; // this is the project cloning above await clone.CreateCopyAsync(jenkins.MainLog, processManager, task, HarnessConfiguration.RootDirectory); var isMac = task.Platform.IsMac(); var canSymlink = task.Platform.CanSymlink(); if (!string.IsNullOrEmpty(mtouch_extra_args)) { clone.Xml.AddExtraMtouchArgs(mtouch_extra_args, task.ProjectPlatform, configuration); } if (!string.IsNullOrEmpty(bundling_extra_args)) { clone.Xml.AddMonoBundlingExtraArgs(bundling_extra_args, task.ProjectPlatform, configuration); } if (!string.IsNullOrEmpty(link_mode)) { clone.Xml.SetNode(isMac ? "LinkMode" : "MtouchLink", link_mode, task.ProjectPlatform, configuration); } if (!string.IsNullOrEmpty(defines)) { clone.Xml.AddAdditionalDefines(defines, task.ProjectPlatform, configuration); if (clone.ProjectReferences != null) { foreach (var pr in clone.ProjectReferences) { pr.Xml.AddAdditionalDefines(defines, task.ProjectPlatform, configuration); pr.Xml.Save(pr.Path); } } } if (!string.IsNullOrEmpty(undefines)) { clone.Xml.RemoveDefines(undefines, task.ProjectPlatform, configuration); if (clone.ProjectReferences != null) { foreach (var pr in clone.ProjectReferences) { pr.Xml.RemoveDefines(undefines, task.ProjectPlatform, configuration); pr.Xml.Save(pr.Path); } } } clone.Xml.SetNode(isMac ? "Profiling" : "MTouchProfiling", profiling ? "True" : "False", task.ProjectPlatform, configuration); if (test_data.MonoNativeLinkMode != MonoNativeLinkMode.None) { var mono_native_link = test_data.MonoNativeLinkMode; if (!canSymlink && mono_native_link == MonoNativeLinkMode.Symlink) { mono_native_link = MonoNativeLinkMode.Static; } MonoNativeHelper.AddProjectDefines(clone.Xml, mono_native_link); } if (test_data.EnableSGenConc) { clone.Xml.SetTopLevelPropertyGroupValue("EnableSGenConc", "true"); } if (test_data.UseThumb) // no need to check the platform, already done at the data iterator { clone.Xml.SetNode("MtouchUseThumb", "true", task.ProjectPlatform, configuration); } if (use_llvm) { clone.Xml.SetTopLevelPropertyGroupValue("MtouchUseLlvm", "true"); } if (!debug && !isMac) { clone.Xml.SetMtouchUseLlvm(true, task.ProjectPlatform, configuration); } if (use_mono_runtime.HasValue) { clone.Xml.SetTopLevelPropertyGroupValue("UseMonoRuntime", use_mono_runtime.Value ? "true" : "false"); } if (!string.IsNullOrEmpty(xammac_arch)) { clone.Xml.SetNode("XamMacArch", xammac_arch, task.ProjectPlatform, configuration); } if (!string.IsNullOrEmpty(runtime_identifer)) { clone.Xml.SetTopLevelPropertyGroupValue("RuntimeIdentifier", runtime_identifer); } clone.Xml.Save(clone.Path); }); ignored |= clone.IsDotNetProject && !jenkins.IncludeDotNet; var build = new MSBuildTask(jenkins: jenkins, testProject: clone, processManager: processManager); build.ProjectConfiguration = configuration; build.ProjectPlatform = task.ProjectPlatform; build.Platform = task.Platform; build.InitialTask = clone_task; build.TestName = clone.Name; T newVariation = creator(build, task, candidates); newVariation.Variation = variation; newVariation.Ignored = ignored ?? task.Ignored; newVariation.BuildOnly = task.BuildOnly; newVariation.TimeoutMultiplier = task.TimeoutMultiplier; newVariation.KnownFailure = known_failure; rv.Add(newVariation); } } return(rv); }