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 static void CreateMacMakefile(IHarness harness, IEnumerable <MacTarget> targets) { var makefile = Path.Combine(HarnessConfiguration.RootDirectory, "Makefile-mac.inc"); using (var writer = new StreamWriter(makefile, false, new UTF8Encoding(false))) { writer.WriteLine(".stamp-configure-projects-mac: Makefile xharness/xharness.exe"); writer.WriteLine("\t$(Q) $(SYSTEM_MONO) --debug $(XIBUILD_EXE_PATH) -t -- $(CURDIR)/xharness/xharness.exe $(XHARNESS_VERBOSITY) --configure --autoconf --rootdir $(CURDIR)"); writer.WriteLine("\t$(Q) touch $@"); writer.WriteLine(); var nuget_restore_dependency = ".stamp-nuget-restore-mac"; writer.WriteLine("PACKAGES_CONFIG:=$(shell git ls-files -- '*.csproj' '*/packages.config' | sed 's/ /\\\\ /g')"); writer.WriteLine($"{nuget_restore_dependency}: tests-mac.sln $(PACKAGES_CONFIG)"); writer.WriteLine("\t$(Q_XBUILD) $(SYSTEM_XIBUILD) -t -- /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore tests-mac.sln"); writer.WriteLine("\t$(Q) touch $@"); var allTargets = new List <MacTarget> (); allTargets.AddRange(targets); List <string> allTargetNames = new List <string> (allTargets.Count); List <string> allTargetCleanNames = new List <string> (allTargets.Count); // special case for those targets that are auto generated from the mono assemblies allTargets.RemoveAll(v => v.IsBCLProject); // build/[install/]run targets for specific test projects. foreach (var target in allTargets) { var make_escaped_simplified_name = target.SimplifiedName.Replace(" ", "\\ "); var make_escaped_name = target.Name.Replace(" ", "\\ "); writer.WriteLine(); if (target.ProjectPath != target.TemplateProjectPath) { writer.WriteLine("# {0} for {1}", make_escaped_simplified_name, target.Suffix.Replace("-", "")); writer.WriteLine(".stamp-configure-projects-mac: {0}", target.TemplateProjectPath.Replace(" ", "\\ ")); writer.WriteLine("{0}: .stamp-configure-projects-mac", target.ProjectPath.Replace(" ", "\\ ")); writer.WriteLine(); } allTargetNames.Add(MakeMacUnifiedTargetName(target, MacTargetNameType.Build)); allTargetCleanNames.Add(MakeMacUnifiedTargetName(target, MacTargetNameType.Clean)); writer.WriteTarget(MakeMacUnifiedTargetName(target, MacTargetNameType.Build), "{0}", target.ProjectPath.Replace(" ", "\\ ") + " " + nuget_restore_dependency); writer.WriteLine("\t$(Q_XBUILD) $(SYSTEM_XIBUILD) -- \"/property:Configuration=$(CONFIG)\" /r /t:Build $(XBUILD_VERBOSITY) \"{0}\"", target.ProjectPath); writer.WriteLine(); writer.WriteTarget(MakeMacUnifiedTargetName(target, MacTargetNameType.Clean), ""); writer.WriteLine("\t$(Q_XBUILD) $(SYSTEM_XIBUILD) -- \"/property:Configuration=$(CONFIG)\" /t:Clean $(XBUILD_VERBOSITY) \"{0}\"", target.ProjectPath); writer.WriteLine(); if (!harness.GetIncludeSystemPermissionTests(TestPlatform.Mac, false)) { writer.WriteTarget(MakeMacUnifiedTargetName(target, MacTargetNameType.Exec), "export DISABLE_SYSTEM_PERMISSION_TESTS=1"); } writer.WriteTarget(MakeMacUnifiedTargetName(target, MacTargetNameType.Exec), ""); if (target.IsNUnitProject) { writer.WriteLine("\t$(Q)rm -f $(CURDIR)/.{0}-failed.stamp", make_escaped_name); var testLibrary = $"{Path.GetDirectoryName (target.ProjectPath)}/bin/$(CONFIG)/{make_escaped_name}.dll"; var log = new MemoryLog(); if (NUnitExecuteTask.TryGetNUnitExecutionSettings(log, target.ProjectPath, testLibrary, out var testExecutable, out var workingDirectory)) { if (testExecutable.EndsWith(".exe", StringComparison.Ordinal)) { testExecutable = "$(SYSTEM_MONO) --debug $(XIBUILD_EXE_PATH) -t -- " + testExecutable; } writer.WriteLine($"\tcd \"{workingDirectory}\" && {testExecutable} \"{testLibrary}\" \"--result=$(abspath $(CURDIR)/{make_escaped_name}-TestResult.xml);format=nunit2\" $(TEST_FIXTURE) --labels=All || touch $(CURDIR)/.{make_escaped_name}-failed.stamp", make_escaped_name, Path.GetDirectoryName(target.ProjectPath)); writer.WriteLine("\t$(Q)[[ -z \"$$BUILD_REPOSITORY\" ]] || ( xsltproc $(TOP)/tests/HtmlTransform.xslt {0}-TestResult.xml > {0}-index.html && echo \"@MonkeyWrench: AddFile: $$PWD/{0}-index.html\")", make_escaped_name); writer.WriteLine("\t$(Q)[[ ! -e .{0}-failed.stamp ]]", make_escaped_name); } else { throw new Exception($"Failed to compute NUNit execution settings:\n" + log.ToString()); } }