[tests] Split the iOS msbuild tests in two. (#9860)

Split the iOS msbuild tests in two:

* Xamarin.MacDev.Tasks.Tests: contains in-process unit tests for tasks.
* Xamarin.MacDev.Tasks: contains larger tests that either invoke targets or a complete
  build. These are currently in-process, but will become out-of-process soon to make
  it possible to run them with dotnet.

Also make the new projects non-iOS-specific, because the macOS msbuild tests will
be moved here as well soon.

There is some duplicated code between these two test projects now (all files
that show up as new are copies of existing files), this will be cleaned up in
later pull requests.
This commit is contained in:
Rolf Bjarne Kvinge 2020-10-15 08:45:43 +02:00 коммит произвёл GitHub
Родитель 5db939f329
Коммит e92809f38c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
78 изменённых файлов: 1071 добавлений и 20 удалений

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

@ -5,8 +5,6 @@ VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.iOS.Tasks.Core", "Xamarin.iOS.Tasks.Core\Xamarin.iOS.Tasks.Core.csproj", "{93E12FA0-089C-4BC8-840F-43CFBC7927C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.iOS.Tasks.Tests", "..\tests\msbuild\Xamarin.iOS.Tasks.Tests\Xamarin.iOS.Tasks.Tests.csproj", "{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.MacDev", "..\external\Xamarin.MacDev\Xamarin.MacDev\Xamarin.MacDev.csproj", "{CC3D9353-20C4-467A-8522-A9DED6F0C753}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.MacDev.Tasks", "Xamarin.MacDev.Tasks\Xamarin.MacDev.Tasks.csproj", "{534D7C5A-0E1C-4C58-9E48-21B1A98919EB}"
@ -21,6 +19,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Mac.Tasks.Core", "X
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Localization.MSBuild", "Xamarin.Localization.MSBuild\Xamarin.Localization.MSBuild.csproj", "{947E3C4C-8891-49D7-B665-23F785489D3F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D669990B-EE95-4282-AAC4-17CA05AE0575}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.MacDev.Tests", "..\tests\msbuild\Xamarin.MacDev.Tests\Xamarin.MacDev.Tests.csproj", "{14A12D59-A630-42F1-BC19-A63A9D87DB3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.MacDev.Tasks.Tests", "..\tests\msbuild\Xamarin.MacDev.Tasks.Tests\Xamarin.MacDev.Tasks.Tests.csproj", "{17E54157-C5DA-414C-8C28-7F642E6E4FB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -37,14 +41,6 @@ Global
{93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Debug-net461|Any CPU.Build.0 = Debug|Any CPU
{93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Debug-netstandard2.0|Any CPU.ActiveCfg = Debug|Any CPU
{93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Debug-netstandard2.0|Any CPU.Build.0 = Debug|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Release|Any CPU.Build.0 = Release|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug-net461|Any CPU.ActiveCfg = Debug-netstandard2.0|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug-net461|Any CPU.Build.0 = Debug-netstandard2.0|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug-netstandard2.0|Any CPU.ActiveCfg = Debug-netstandard2.0|Any CPU
{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug-netstandard2.0|Any CPU.Build.0 = Debug-netstandard2.0|Any CPU
{CC3D9353-20C4-467A-8522-A9DED6F0C753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC3D9353-20C4-467A-8522-A9DED6F0C753}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC3D9353-20C4-467A-8522-A9DED6F0C753}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -101,6 +97,22 @@ Global
{947E3C4C-8891-49D7-B665-23F785489D3F}.Debug-net461|Any CPU.Build.0 = Debug|Any CPU
{947E3C4C-8891-49D7-B665-23F785489D3F}.Debug-netstandard2.0|Any CPU.ActiveCfg = Debug|Any CPU
{947E3C4C-8891-49D7-B665-23F785489D3F}.Debug-netstandard2.0|Any CPU.Build.0 = Debug|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Release|Any CPU.Build.0 = Release|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Debug-net461|Any CPU.ActiveCfg = Debug|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Debug-net461|Any CPU.Build.0 = Debug|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Debug-netstandard2.0|Any CPU.ActiveCfg = Debug|Any CPU
{14A12D59-A630-42F1-BC19-A63A9D87DB3B}.Debug-netstandard2.0|Any CPU.Build.0 = Debug|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Release|Any CPU.Build.0 = Release|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Debug-net461|Any CPU.ActiveCfg = Debug-netstandard2.0|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Debug-net461|Any CPU.Build.0 = Debug-netstandard2.0|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Debug-netstandard2.0|Any CPU.ActiveCfg = Debug-netstandard2.0|Any CPU
{17E54157-C5DA-414C-8C28-7F642E6E4FB0}.Debug-netstandard2.0|Any CPU.Build.0 = Debug-netstandard2.0|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -134,4 +146,8 @@ Global
$2.scope = text/x-csharp
$2.NewLinesForBracesInTypes = False
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{14A12D59-A630-42F1-BC19-A63A9D87DB3B} = {D669990B-EE95-4282-AAC4-17CA05AE0575}
{17E54157-C5DA-414C-8C28-7F642E6E4FB0} = {D669990B-EE95-4282-AAC4-17CA05AE0575}
EndGlobalSection
EndGlobal

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

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo ("Xamarin.iOS.Tasks.Tests")]
[assembly: InternalsVisibleTo ("Xamarin.MacDev.Tasks.Tests")]
[assembly: InternalsVisibleTo ("Xamarin.MacDev.Tests")]

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

@ -214,11 +214,15 @@ killall:
@killall Touch.Server >/dev/null 2>&1 || true
NUNIT_MSBUILD_DIR=$(TOP)/packages/NUnit.Runners.2.6.4/tools/lib
test-ios-tasks: verify-system-vsmac-xcode-match
$(SYSTEM_MSBUILD) $(TOP)/tests/msbuild/Xamarin.iOS.Tasks.Tests/Xamarin.iOS.Tasks.Tests.csproj /p:Configuration=Debug
cd $(TOP)/tests/msbuild/Xamarin.iOS.Tasks.Tests && $(SYSTEM_XIBUILD) -t -- $(abspath $(TOP)/tools/nunit3-console-3.11.1) $(abspath $(TOP)/tests/msbuild/Xamarin.iOS.Tasks.Tests/bin/Debug/net461/Xamarin.iOS.Tasks.Tests.dll) "--result=$(abspath $(CURDIR)/TestResults_Xamarin.iOS.Tasks.Tests.xml);format=nunit2" -labels=Before $(TEST_FIXTURE) || touch $(CURDIR)/.$@-failed-stamp
@[[ -z "$$BUILD_REPOSITORY" ]] || ( xsltproc $(TOP)/tests/HtmlTransform.xslt $(CURDIR)/TestResults_Xamarin.iOS.Tasks.Tests.xml > $(TOP)/tests/index.html && echo "@MonkeyWrench: AddFile: $$PWD/index.html" )
@if test -e $(CURDIR)/.$@-failed-stamp; then rm $(CURDIR)/.$@-failed-stamp; exit 1; fi
test-ios-tasks: test-macdev-tests test-macdev-tasks
test-macdev-tests: verify-system-vsmac-xcode-match
$(SYSTEM_MSBUILD) $(TOP)/tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj /p:Configuration=Debug /r
cd $(TOP)/tests/msbuild/Xamarin.MacDev.Tests && $(SYSTEM_XIBUILD) -t -- $(abspath $(TOP)/tools/nunit3-console-3.11.1) $(abspath $(TOP)/tests/msbuild/Xamarin.MacDev.Tests/bin/Debug/net461/Xamarin.MacDev.Tests.dll) "--result=$(abspath $(CURDIR)/TestResults_Xamarin.MacDev.Tests.xml);format=nunit2" -labels=Before $(TEST_FIXTURE)
test-macdev-tasks: verify-system-vsmac-xcode-match
$(SYSTEM_MSBUILD) $(TOP)/tests/msbuild/Xamarin.MacDev.Tasks.Tests/Xamarin.MacDev.Tasks.Tests.csproj /p:Configuration=Debug /r
cd $(TOP)/tests/msbuild/Xamarin.MacDev.Tasks.Tests && $(SYSTEM_XIBUILD) -t -- $(abspath $(TOP)/tools/nunit3-console-3.11.1) $(abspath $(TOP)/tests/msbuild/Xamarin.MacDev.Tasks.Tests/bin/Debug/net461/Xamarin.MacDev.Tasks.Tests.dll) "--result=$(abspath $(CURDIR)/TestResults_Xamarin.MacDev.Tasks.Tests.xml);format=nunit2" -labels=Before $(TEST_FIXTURE)
test-install-sources:
$(SYSTEM_XIBUILD) -- $(TOP)/tools/install-source/InstallSourcesTests/InstallSourcesTests.csproj

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

До

Ширина:  |  Высота:  |  Размер: 4.3 KiB

После

Ширина:  |  Высота:  |  Размер: 4.3 KiB

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

До

Ширина:  |  Высота:  |  Размер: 20 KiB

После

Ширина:  |  Высота:  |  Размер: 20 KiB

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

До

Ширина:  |  Высота:  |  Размер: 9.0 KiB

После

Ширина:  |  Высота:  |  Размер: 9.0 KiB

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

До

Ширина:  |  Высота:  |  Размер: 106 KiB

После

Ширина:  |  Высота:  |  Размер: 106 KiB

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

До

Ширина:  |  Высота:  |  Размер: 26 KiB

После

Ширина:  |  Высота:  |  Размер: 26 KiB

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

До

Ширина:  |  Высота:  |  Размер: 273 KiB

После

Ширина:  |  Высота:  |  Размер: 273 KiB

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

@ -18,7 +18,7 @@ namespace Xamarin.iOS.Tasks {
Assert.IsFalse (task.Execute (), "Execute failure");
Assert.AreEqual (1, Engine.Logger.ErrorEvents.Count, "ErrorCount");
Assert.That (Engine.Logger.ErrorEvents [0].Message, Does.Match ("Error loading '.*/Xamarin.iOS.Tasks.Tests.dll': Unknown image format."), "ErrorMessage");
Assert.That (Engine.Logger.ErrorEvents [0].Message, Does.Match ("Error loading '.*/Xamarin.MacDev.Tasks.Tests.dll': Unknown image format."), "ErrorMessage");
}
[Test]

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

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.Tests;
[SetUpFixture]
public class AssemblySetup {
[OneTimeSetUp]
public void AssemblyInitialization ()
{
// Seems like the ServiceHubUniqueLogDir environment variable is set when executing unit tests from within VS
var is_in_vsmac = !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("ServiceHubUniqueLogDir"));
const string msbuild_exe_path = "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin/MSBuild.dll";
if (is_in_vsmac) {
var env = new Dictionary<string, string> {
{ "MD_APPLE_SDK_ROOT", Path.GetDirectoryName (Path.GetDirectoryName (Configuration.xcode_root)) },
{ "TargetFrameworkFallbackSearchPaths", Path.Combine (Configuration.TargetDirectoryXI, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks") },
{ "MSBuildExtensionsPathFallbackPathsOverride", Path.Combine (Configuration.TargetDirectoryXI, "Library", "Frameworks", "Mono.framework", "External", "xbuild") },
{ "MD_MTOUCH_SDK_ROOT", Path.Combine (Configuration.TargetDirectoryXI, "Library", "Frameworks", "Xamarin.iOS.framework", "Versions", "Current") },
{ "MSBUILD_EXE_PATH", msbuild_exe_path },
};
foreach (var kvp in env)
Environment.SetEnvironmentVariable (kvp.Key, kvp.Value);
Console.WriteLine ($"Detected that we're running inside Visual Studio, and the environment has been configured.");
} else {
Console.WriteLine ("Detected that we're not running inside Visual Studio, and thus will not set MSBUILD_EXE_PATH.");
}
}
}

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

@ -0,0 +1,220 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using Microsoft.Build.Framework;
using NUnit.Framework;
using Microsoft.Build.Utilities;
namespace Xamarin.iOS.Tasks
{
public class Logger : ILogger
{
public List<CustomBuildEventArgs> CustomEvents {
get; set;
}
public List<BuildErrorEventArgs> ErrorEvents {
get; set;
}
public List<BuildMessageEventArgs> MessageEvents {
get; set;
}
public List<BuildWarningEventArgs> WarningsEvents {
get; set;
}
public void Initialize (IEventSource eventSource)
{
CustomEvents = new List<CustomBuildEventArgs> ();
ErrorEvents = new List<BuildErrorEventArgs> ();
MessageEvents = new List<BuildMessageEventArgs> ();
WarningsEvents = new List<BuildWarningEventArgs> ();
eventSource.CustomEventRaised += (object sender, CustomBuildEventArgs e) => CustomEvents.Add (e);
eventSource.ErrorRaised += (object sender, BuildErrorEventArgs e) => ErrorEvents.Add (e);
eventSource.MessageRaised += (object sender, BuildMessageEventArgs e) => MessageEvents.Add (e);
eventSource.WarningRaised += (object sender, BuildWarningEventArgs e) => WarningsEvents.Add (e);
}
public void Shutdown ()
{
throw new NotImplementedException ();
}
public string Parameters {
get; set;
}
public LoggerVerbosity Verbosity {
get; set;
}
public void Clear ()
{
CustomEvents.Clear ();
ErrorEvents.Clear ();
MessageEvents.Clear ();
WarningsEvents.Clear ();
}
}
// Stolen from xbuild.
class ConsoleReportPrinter
{
string prefix, postfix;
bool color_supported;
TextWriter writer;
string [] colorPrefixes;
public ConsoleReportPrinter ()
: this (Console.Out)
{
}
public ConsoleReportPrinter (TextWriter writer)
{
this.writer = writer;
string term = Environment.GetEnvironmentVariable ("TERM");
bool xterm_colors = false;
color_supported = false;
switch (term){
case "xterm":
case "rxvt":
case "rxvt-unicode":
if (Environment.GetEnvironmentVariable ("COLORTERM") != null){
xterm_colors = true;
}
break;
case "xterm-color":
case "xterm-256color":
xterm_colors = true;
break;
}
if (!xterm_colors)
return;
if (!(UnixUtils.isatty (1) && UnixUtils.isatty (2)))
return;
color_supported = true;
PopulateColorPrefixes ();
postfix = "\x001b[0m";
}
void PopulateColorPrefixes ()
{
colorPrefixes = new string [16];
colorPrefixes [(int)ConsoleColor.Black] = GetForeground ("black");
colorPrefixes [(int)ConsoleColor.DarkBlue] = GetForeground ("blue");
colorPrefixes [(int)ConsoleColor.DarkGreen] = GetForeground ("green");
colorPrefixes [(int)ConsoleColor.DarkCyan] = GetForeground ("cyan");
colorPrefixes [(int)ConsoleColor.DarkRed] = GetForeground ("red");
colorPrefixes [(int)ConsoleColor.DarkMagenta] = GetForeground ("magenta");
colorPrefixes [(int)ConsoleColor.DarkYellow] = GetForeground ("yellow");
colorPrefixes [(int)ConsoleColor.DarkGray] = GetForeground ("grey");
colorPrefixes [(int)ConsoleColor.Gray] = GetForeground ("brightgrey");
colorPrefixes [(int)ConsoleColor.Blue] = GetForeground ("brightblue");
colorPrefixes [(int)ConsoleColor.Green] = GetForeground ("brightgreen");
colorPrefixes [(int)ConsoleColor.Cyan] = GetForeground ("brightcyan");
colorPrefixes [(int)ConsoleColor.Red] = GetForeground ("brightred");
colorPrefixes [(int)ConsoleColor.Magenta] = GetForeground ("brightmagenta");
colorPrefixes [(int)ConsoleColor.Yellow] = GetForeground ("brightyellow");
colorPrefixes [(int)ConsoleColor.White] = GetForeground ("brightwhite");
}
public void SetForeground (ConsoleColor color)
{
if (color_supported)
prefix = colorPrefixes [(int)color];
}
public void ResetColor ()
{
prefix = "\x001b[0m";
}
static int NameToCode (string s)
{
switch (s) {
case "black":
return 0;
case "red":
return 1;
case "green":
return 2;
case "yellow":
return 3;
case "blue":
return 4;
case "magenta":
return 5;
case "cyan":
return 6;
case "grey":
case "white":
return 7;
}
return 7;
}
//
// maps a color name to its xterm color code
//
static string GetForeground (string s)
{
string highcode;
if (s.StartsWith ("bright")) {
highcode = "1;";
s = s.Substring (6);
} else
highcode = "";
return "\x001b[" + highcode + (30 + NameToCode (s)).ToString () + "m";
}
static string GetBackground (string s)
{
return "\x001b[" + (40 + NameToCode (s)).ToString () + "m";
}
string FormatText (string txt)
{
if (prefix != null && color_supported)
return prefix + txt + postfix;
return txt;
}
public void Print (string message)
{
writer.Write (FormatText (message));
}
}
class UnixUtils {
[System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")]
extern static int _isatty (int fd);
public static bool isatty (int fd)
{
try {
return _isatty (fd) == 1;
} catch {
return false;
}
}
}
}

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

@ -0,0 +1,561 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Utilities;
using NUnit.Framework;
using Xamarin.MacDev;
using Xamarin.Tests;
using Xamarin.Utils;
namespace Xamarin.iOS.Tasks
{
public enum ExecutionMode {
InProcess,
MSBuild,
DotNet,
}
public abstract class TestBase
{
protected static class TargetName
{
public static string Build = "Build";
public static string Clean = "Clean";
public static string CollectBundleResources = "_CollectBundleResources";
public static string CompileImageAssets = "_CompileImageAssets";
public static string CompileInterfaceDefinitions = "_CompileInterfaceDefinitions";
public static string CopyResourcesToBundle = "_CopyResourcesToBundle";
public static string DetectAppManifest = "_DetectAppManifest";
public static string GenerateBundleName = "_GenerateBundleName";
public static string PackLibraryResources = "_PackLibraryResources";
public static string ResolveReferences = "ResolveReferences";
}
protected static string GetTestDirectory (string mode = null, ExecutionMode? executionMode = null)
{
var assembly_path = Assembly.GetExecutingAssembly ().Location;
if (string.IsNullOrEmpty (mode)) {
if (assembly_path.Contains ("netstandard2.0"))
mode = "netstandard2.0";
else if (assembly_path.Contains ("net461"))
mode = "net461";
else
mode = "unknown";
}
var rv = Configuration.CloneTestDirectory (Configuration.TestProjectsDirectory, mode);
if (executionMode == ExecutionMode.DotNet)
Configuration.CopyDotNetSupportingFiles (rv);
return rv;
}
public string [] ExpectedAppFiles = { };
public string [] UnexpectedAppFiles = { "monotouch.dll" };
public string[] GetCoreAppFiles (string platform, string config, string managedExe, string nativeExe)
{
var coreFiles = new List<string> ();
if (TargetFrameworkIdentifier == "Xamarin.WatchOS") {
coreFiles.Add ("Xamarin.WatchOS.dll");
if (config == "Debug")
coreFiles.Add ("Xamarin.WatchOS.pdb");
} else if (TargetFrameworkIdentifier == "Xamarin.TVOS") {
coreFiles.Add ("Xamarin.TVOS.dll");
if (config == "Debug")
coreFiles.Add ("Xamarin.TVOS.pdb");
} else {
coreFiles.Add ("Xamarin.iOS.dll");
if (config == "Debug")
coreFiles.Add ("Xamarin.iOS.pdb");
}
coreFiles.Add ("mscorlib.dll");
if (config == "Debug")
coreFiles.Add ("mscorlib.pdb");
coreFiles.Add (managedExe);
if (config == "Debug")
coreFiles.Add (Path.ChangeExtension (managedExe, ".pdb"));
coreFiles.Add (nativeExe);
return coreFiles.ToArray ();
}
public Logger Logger {
get; set;
}
public TestEngine Engine {
get; private set;
}
public Project LibraryProject {
get; private set;
}
public ProjectInstance LibraryProjectInstance {
get; set;
}
public Project MonoTouchProject {
get; private set;
}
public ProjectInstance MonoTouchProjectInstance {
get; set;
}
public string LibraryProjectBinPath;
public string LibraryProjectObjPath;
public string LibraryProjectPath;
public string LibraryProjectCSProjPath;
public string MonoTouchProjectBinPath;
public string MonoTouchProjectObjPath;
public string MonoTouchProjectPath;
public string MonoTouchProjectCSProjPath;
public string AppBundlePath;
public string TempDir {
get; set;
}
public ProjectPaths SetupProjectPaths (string projectName, string csprojName, string baseDir = "../", bool includePlatform = true, string platform = "iPhoneSimulator", string config = "Debug", string projectPath = null, bool is_dotnet = false)
{
var testsBase = GetTestDirectory ();
if (projectPath == null) {
if (Path.IsPathRooted (baseDir)) {
projectPath = Path.Combine (baseDir, projectName);
} else {
if (baseDir.StartsWith ("../", StringComparison.Ordinal))
baseDir = baseDir.Substring (3); // Tests have been relocated, which means the given relative base dir is not correct anymore, so fix it.
projectPath = Path.Combine (testsBase, baseDir, projectName);
}
}
string binPath;
string objPath;
if (is_dotnet) {
var targetPlatform = "net5.0";
var subdir = string.Empty;
var targetPlatformSuffix = string.Empty;
switch (TargetFrameworkIdentifier) {
case "Xamarin.iOS":
subdir = platform == "iPhone" ? "ios-arm64" : "ios-x64";
targetPlatformSuffix = "ios";
break;
case "Xamarin.TVOS":
subdir = platform == "iPhone" ? "tvos-arm64" : "tvos-x64";
targetPlatformSuffix = "tvos";
break;
case "Xamarin.WatchOS":
subdir = platform == "iPhone" ? "watchos-arm" : "watchos-x86";
targetPlatformSuffix = "watchos";
break;
default:
throw new NotImplementedException ($"Unknown TargetFrameworkIdentifier: {TargetFrameworkIdentifier}");
}
targetPlatform += "-" + targetPlatformSuffix;
binPath = Path.Combine (projectPath, "bin", platform, config, targetPlatform, subdir);
objPath = Path.Combine (projectPath, "obj", platform, config, targetPlatform, subdir);
} else {
binPath = includePlatform ? Path.Combine (projectPath, "bin", platform, config) : Path.Combine (projectPath, "bin", config);
objPath = includePlatform ? Path.Combine (projectPath, "obj", platform, config) : Path.Combine (projectPath, "obj", config);
}
return new ProjectPaths {
ProjectPath = projectPath,
ProjectBinPath = binPath,
ProjectObjPath = objPath,
ProjectCSProjPath = Path.Combine (projectPath, csprojName + ".csproj"),
AppBundlePath = Path.Combine (binPath, projectName.Replace (" ", "") + ".app"),
};
}
public ProjectPaths SetupProjectPaths (string projectName, string baseDir = "../", bool includePlatform = true, string platform = "iPhoneSimulator", string config = "Debug", string projectPath = null)
{
return SetupProjectPaths (projectName, projectName, baseDir, includePlatform, platform, config, projectPath);
}
[SetUp]
public virtual void Setup ()
{
var mtouchPaths = SetupProjectPaths ("MySingleView");
MonoTouchProjectBinPath = mtouchPaths.ProjectBinPath;
MonoTouchProjectObjPath = mtouchPaths.ProjectObjPath;
MonoTouchProjectCSProjPath = mtouchPaths.ProjectCSProjPath;
MonoTouchProjectPath = mtouchPaths.ProjectPath;
AppBundlePath = mtouchPaths.AppBundlePath;
var libraryPaths = SetupProjectPaths ("MyLibrary", "../MySingleView/", false);
LibraryProjectBinPath = libraryPaths.ProjectBinPath;
LibraryProjectObjPath = libraryPaths.ProjectObjPath;
LibraryProjectPath = libraryPaths.ProjectPath;
LibraryProjectCSProjPath = libraryPaths.ProjectCSProjPath;
SetupEngine ();
MonoTouchProject = SetupProject (Engine, MonoTouchProjectCSProjPath);
MonoTouchProjectInstance = MonoTouchProject.CreateProjectInstance ();
LibraryProject = SetupProject (Engine, LibraryProjectCSProjPath);
LibraryProjectInstance = LibraryProject.CreateProjectInstance ();
CleanUp ();
}
public void SetupEngine ()
{
Engine = new TestEngine ();
}
public Project SetupProject (TestEngine engine, string projectPath)
{
return engine.ProjectCollection.LoadProject (projectPath);
}
public virtual string TargetFrameworkIdentifier {
get {
return "Xamarin.iOS";
}
}
public bool IsWatchOS {
get { return TargetFrameworkIdentifier == "Xamarin.WatchOS"; }
}
public bool IsTVOS {
get { return TargetFrameworkIdentifier == "Xamarin.TVOS"; }
}
public void CleanUp () {
var paths = SetupProjectPaths ("MySingleView");
MonoTouchProjectPath = paths.ProjectPath;
TempDir = Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "ScratchDir");
SafeDelete (TempDir);
Directory.CreateDirectory (TempDir);
// Ensure the bin and obj directories are cleared
SafeDelete (Path.Combine (MonoTouchProjectPath, "bin"));
SafeDelete (Path.Combine (MonoTouchProjectPath, "obj"));
SafeDelete (Path.Combine (LibraryProjectPath, "bin"));
SafeDelete (Path.Combine (LibraryProjectPath, "obj"));
// Reset all the write times as we deliberately set some in the future for our tests
foreach (var file in Directory.GetFiles (MonoTouchProjectPath, "*.*", SearchOption.AllDirectories))
File.SetLastWriteTimeUtc (file, DateTime.UtcNow);
foreach (var file in Directory.GetFiles (LibraryProjectPath, "*.*", SearchOption.AllDirectories))
File.SetLastWriteTimeUtc (file, DateTime.UtcNow);
Engine.UnloadAllProjects ();
Engine = new TestEngine ();
}
protected void SafeDelete (string path)
{
try {
if (Directory.Exists (path))
Directory.Delete (path, true);
else if (File.Exists (path))
File.Delete (path);
} catch {
}
}
public void TestFilesDoNotExist(string baseDir, IEnumerable<string> files)
{
foreach (var v in files.Select (s => Path.Combine (baseDir, s)))
Assert.IsFalse (File.Exists (v) || Directory.Exists (v), "Unexpected file: {0} exists", v);
}
public void TestFilesExists (string baseDir, string[] files)
{
foreach (var v in files.Select (s => Path.Combine (baseDir, s)))
Assert.IsTrue (File.Exists (v) || Directory.Exists (v), "Expected file: {0} does not exist", v);
}
public void TestFilesExists (string [] baseDirs, string [] files)
{
if (baseDirs.Length == 1) {
TestFilesExists (baseDirs [0], files);
} else {
foreach (var file in files)
Assert.IsTrue (baseDirs.Select (s => File.Exists (Path.Combine (s, file))).Any (v => v), $"Expected file: {file} does not exist in any of the directories: {string.Join (", ", baseDirs)}");
}
}
public void TestStoryboardC (string path)
{
Assert.IsTrue (Directory.Exists (path), "Storyboard {0} does not exist", path);
Assert.IsTrue (File.Exists (Path.Combine (path, "Info.plist")));
TestPList (path, new string [] {"CFBundleVersion", "CFBundleExecutable"});
}
public void TestPList (string path, string[] keys)
{
var plist = PDictionary.FromFile (Path.Combine (path, "Info.plist"));
foreach (var x in keys) {
Assert.IsTrue (plist.ContainsKey (x), "Key {0} is not present in {1} Info.plist", x, path);
Assert.IsNotEmpty (((PString)plist[x]).Value, "Key {0} is empty in {1} Info.plist", x, path);
}
}
[TearDown]
public virtual void Teardown ()
{
SafeDelete (TempDir);
}
public T CreateTask<T> () where T : Task, new()
{
var t = new T ();
t.BuildEngine = Engine;
return t;
}
/// <summary>
/// Executes the task and log its error messages.</summary>
/// <remarks>
/// This is the prefered way to run tasks as we want error messages to show up in the test results.</remarks>
/// <param name="task">An msbuild task.</param>
/// <param name="expectedErrorCount">Expected error count. 0 by default.</param>
public void ExecuteTask (Task task, int expectedErrorCount = 0)
{
task.Execute ();
if (expectedErrorCount != Engine.Logger.ErrorEvents.Count) {
string messages = string.Empty;
if (Engine.Logger.ErrorEvents.Count > 0) {
messages = "\n\t" + string.Join ("\n\t", Engine.Logger.ErrorEvents.Select ((v) => v.Message).ToArray ());
}
Assert.AreEqual (expectedErrorCount, Engine.Logger.ErrorEvents.Count, "#RunTask-ErrorCount" + messages);
}
}
protected string CreateTempFile (string path)
{
path = Path.Combine (TempDir, path);
Directory.CreateDirectory (Path.GetDirectoryName (path));
using (new FileStream (path, FileMode.CreateNew)) {}
return path;
}
protected DateTime GetLastModified (string file)
{
if (Path.GetExtension (file) == ".nib" && !File.Exists (file))
file = Path.Combine (file, "runtime.nib");
if (!File.Exists (file))
Assert.Fail ("Expected file '{0}' did not exist", file);
return File.GetLastWriteTimeUtc (file);
}
protected void RemoveItemsByName (Project project, string itemName)
{
project.RemoveItems (project.GetItems (itemName));
}
protected string SetPListKey (string key, PObject value)
{
var paths = SetupProjectPaths ("MySingleView");
var plist = PDictionary.FromFile (Path.Combine (paths.ProjectPath, "Info.plist"));
if (value == null)
plist.Remove (key);
else
plist [key] = value;
var modifiedPListPath = Path.Combine (TempDir, "modified.plist");
plist.Save (modifiedPListPath);
return modifiedPListPath;
}
protected void Touch (string file)
{
if (!File.Exists (file))
Assert.Fail ("Expected file '{0}' did not exist", file);
EnsureFilestampChange ();
File.SetLastWriteTimeUtc (file, DateTime.UtcNow);
EnsureFilestampChange ();
}
static bool? is_apfs;
public static bool IsAPFS {
get {
if (!is_apfs.HasValue) {
var exit_code = ExecutionHelper.Execute ("/bin/df", new string[] { "-t", "apfs", "/" }, out var output, TimeSpan.FromSeconds (10));
is_apfs = exit_code == 0 && output.Trim ().Split ('\n').Length >= 2;
}
return is_apfs.Value;
}
}
public static void EnsureFilestampChange ()
{
if (IsAPFS)
return;
Thread.Sleep (1000);
}
public void RunTarget (Project project, string target, int expectedErrorCount = 0)
{
RunTarget (project, null, target, ExecutionMode.InProcess, expectedErrorCount);
}
public void RunTarget (Project project, string project_path, string target, ExecutionMode executionMode = ExecutionMode.InProcess, int expectedErrorCount = 0)
{
if (executionMode == ExecutionMode.InProcess) {
RunTargetOnInstance (project.CreateProjectInstance (), target, expectedErrorCount);
return;
}
var platform = Engine.ProjectCollection.GetGlobalProperty ("Platform")?.EvaluatedValue;
var configuration = Engine.ProjectCollection.GetGlobalProperty ("Configuration")?.EvaluatedValue;
var dict = new Dictionary<string, string> ();
if (!string.IsNullOrEmpty (platform))
dict ["Platform"] = platform;
if (!string.IsNullOrEmpty (configuration))
dict ["Configuration"] = configuration;
ExecutionResult rv;
switch (executionMode) {
case ExecutionMode.DotNet:
rv = Dotnet (target, project_path, dict, assert_success: expectedErrorCount == 0);
break;
case ExecutionMode.MSBuild:
rv = MSBuild (project_path, target, dict, assert_success: expectedErrorCount == 0);
break;
default:
throw new NotImplementedException ($"Unknown excecution mode: {executionMode}");
}
Assert.AreEqual (expectedErrorCount, rv.ExitCode, "ExitCode/ExpectedErrorCount");
}
public ExecutionResult Dotnet (string command, string project, Dictionary<string, string> properties, bool assert_success = true)
{
return DotNet.Execute (command, project, properties, assert_success: assert_success);
}
public ExecutionResult MSBuild (string project, string target, Dictionary<string, string> properties, string verbosity = "diagnostic", bool assert_success = true)
{
if (!File.Exists (project))
throw new FileNotFoundException ($"The project file '{project}' does not exist.");
var args = new List<string> ();
args.Add ("--");
args.Add ($"/t:{target}");
args.Add (project);
if (properties != null) {
foreach (var prop in properties)
args.Add ($"/p:{prop.Key}={prop.Value}");
}
if (!string.IsNullOrEmpty (verbosity))
args.Add ($"/verbosity:{verbosity}");
args.Add ($"/bl:{Path.Combine (Path.GetDirectoryName (project), "log.binlog")}");
var output = new StringBuilder ();
var executable = Configuration.XIBuildPath;
var rv = ExecutionHelper.Execute (executable, args, null, output, output, workingDirectory: Path.GetDirectoryName (project), timeout: TimeSpan.FromMinutes (10));
if (assert_success && rv != 0) {
Console.WriteLine ($"'{executable} {StringUtils.FormatArguments (args)}' failed with exit code {rv}.");
Console.WriteLine (output);
Assert.AreEqual (0, rv, $"Exit code: {executable} {StringUtils.FormatArguments (args)}");
}
return new ExecutionResult {
StandardOutput = output,
StandardError = output,
ExitCode = rv,
};
}
public void RunTargetOnInstance (ProjectInstance instance, string target, int expectedErrorCount = 0)
{
Engine.BuildProject (instance, new [] { target }, new Hashtable { {"Platform", "iPhone"} });
if (expectedErrorCount != Engine.Logger.ErrorEvents.Count) {
string messages = string.Empty;
if (Engine.Logger.ErrorEvents.Count > 0) {
messages = "\n\t" + string.Join ("\n\t", Engine.Logger.ErrorEvents.Select ((v) => v.Message).ToArray ());
}
Assert.AreEqual (expectedErrorCount, Engine.Logger.ErrorEvents.Count, "#RunTarget-ErrorCount" + messages);
}
}
public void RunTarget_WithErrors (Project project, string target)
{
RunTarget_WithErrors (project.CreateProjectInstance (), target);
}
public void RunTarget_WithErrors (ProjectInstance instance, string target)
{
Engine.BuildProject (instance, new [] { target }, new Hashtable ());
Assert.IsTrue (Engine.Logger.ErrorEvents.Count > 0, "#RunTarget-HasExpectedErrors");
}
protected void AssertValidDeviceBuild (string platform)
{
if (!Xamarin.Tests.Configuration.include_device && platform == "iPhone")
Assert.Ignore ("This build does not include device support.");
}
public static void NugetRestore (string project)
{
var rv = ExecutionHelper.Execute ("nuget", new string[] { "restore", project }, out var output);
if (rv != 0) {
Console.WriteLine ("nuget restore failed:");
Console.WriteLine (output);
Assert.Fail ($"'nuget restore' failed for {project}");
}
}
/// <summary>
/// Returns true if a target was skipped.
/// Originally from: https://github.com/xamarin/xamarin-android/blob/320cb0f66730e7107cc17310b99cd540605a234d/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/BuildOutput.cs#L48-L62
/// </summary>
public bool IsTargetSkipped (string target)
{
foreach (var line in Engine.Logger.MessageEvents.Select (m => m.Message)) {
if (line.Contains ($"Building target \"{target}\" completely")
|| line.Contains ($"Done building target \"{target}\""))
return false;
if (line.Contains ($"Target {target} skipped due to ")
|| line.Contains ($"Skipping target \"{target}\" because it has no ") //NOTE: message can say `inputs` or `outputs`
|| line.Contains ($"Target \"{target}\" skipped, due to")
|| line.Contains ($"Skipping target \"{target}\" because its outputs are up-to-date")
|| line.Contains ($"target {target}, skipping")
|| line.Contains ($"Skipping target \"{target}\" because all output files are up-to-date"))
return true;
}
return false;
}
}
public class ProjectPaths {
public string ProjectPath { get; set; }
public string ProjectBinPath { get; set; }
public string ProjectObjPath { get; set; }
public string ProjectCSProjPath { get; set; }
public string AppBundlePath { get; set; }
}
}

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

@ -0,0 +1,129 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using Microsoft.Build.Framework;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Logging;
using NUnit.Framework;
using Microsoft.Build.Utilities;
namespace Xamarin.iOS.Tasks
{
public class TestEngine : IBuildEngine, IBuildEngine2, IBuildEngine3, IBuildEngine4
{
public Logger Logger {
get; set;
}
public TestEngine ()
{
Logger = new Logger ();
ProjectCollection = new ProjectCollection ();
ProjectCollection.RegisterLogger (Logger);
var printer = new ConsoleReportPrinter ();
var cl = new ConsoleLogger (LoggerVerbosity.Diagnostic, printer.Print, printer.SetForeground, printer.ResetColor);
ProjectCollection.RegisterLogger (cl);
}
public bool BuildProjectFile (string projectFileName, string [] targetNames, IDictionary globalProperties, IDictionary targetOutputs)
{
throw new NotImplementedException ();
}
public bool BuildProject (ProjectInstance instance, string [] targetNames, IDictionary globalProperties)
{
if (globalProperties != null) {
foreach (DictionaryEntry de in globalProperties) {
//Note: trying to set this on the project causes the project to be added to the PC
// again, which of course, fails
instance.SetProperty ((string)de.Key, (string)de.Value);
}
}
//FIXME: assumption that we are still using the same PC!
return instance.Build (targetNames, ProjectCollection.Loggers);
}
public void LogCustomEvent (CustomBuildEventArgs e)
{
Logger.CustomEvents.Add (e);
}
public void LogErrorEvent (BuildErrorEventArgs e)
{
Logger.ErrorEvents.Add (e);
}
public void LogMessageEvent (BuildMessageEventArgs e)
{
Logger.MessageEvents.Add (e);
}
public void LogWarningEvent (BuildWarningEventArgs e)
{
Logger.WarningsEvents.Add (e);
}
public void UnloadAllProjects ()
{
ProjectCollection.UnloadAllProjects ();
}
public int ColumnNumberOfTaskNode {
get { return 0; }
}
public bool ContinueOnError {
get { return true; }
}
public int LineNumberOfTaskNode {
get {return 0;}
}
public string ProjectFileOfTaskNode {
get { return ""; }
}
public ProjectCollection ProjectCollection { get; set; }
private Dictionary<object, object> Tasks = new Dictionary<object, object> ();
void IBuildEngine4.RegisterTaskObject (object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
{
Tasks [key] = obj;
}
object IBuildEngine4.GetRegisteredTaskObject (object key, RegisteredTaskObjectLifetime lifetime)
{
Tasks.TryGetValue (key, out object value);
return value;
}
object IBuildEngine4.UnregisterTaskObject (object key, RegisteredTaskObjectLifetime lifetime)
{
if (Tasks.TryGetValue (key, out object value)) {
Tasks.Remove (key);
}
return value;
}
BuildEngineResult IBuildEngine3.BuildProjectFilesInParallel (string [] projectFileNames, string [] targetNames, IDictionary [] globalProperties, IList<string> [] removeGlobalProperties, string [] toolsVersion, bool returnTargetOutputs)
{
throw new NotImplementedException ();
}
void IBuildEngine3.Yield () { }
void IBuildEngine3.Reacquire () { }
bool IBuildEngine2.BuildProjectFile (string projectFileName, string [] targetNames, IDictionary globalProperties, IDictionary targetOutputs, string toolsVersion) => true;
bool IBuildEngine2.BuildProjectFilesInParallel (string [] projectFileNames, string [] targetNames, IDictionary [] globalProperties, IDictionary [] targetOutputsPerProject, string [] toolsVersion, bool useResultsCache, bool unloadProjectsOnCompletion) => true;
bool IBuildEngine2.IsRunningMultipleNodes => false;
}
}

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

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DisableTransitiveProjectReferences>true</DisableTransitiveProjectReferences>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<!--
The task assembly (Xamarin.iOS.Tasks.dll) is ILMerged, which really
confuses VSfM when using a project reference to the task assembly project
file, so instead use a reference to the final Xamarin.iOS.Tasks.dll
assembly instead. This approach requires us to manually build the task
assembly before building the test assembly (the BuildTasksAssembly
target).
-->
<ItemGroup>
<Reference Include="Microsoft.Build" HintPath="$(MSBuildBinPath)\Microsoft.Build.dll" />
<Reference Include="Microsoft.Build.Framework" HintPath="$(MSBuildBinPath)\Microsoft.Build.Framework.dll" />
<Reference Include="Microsoft.Build.Tasks.Core" HintPath="$(MSBuildBinPath)\Microsoft.Build.Tasks.Core.dll" />
<Reference Include="Microsoft.Build.Utilities.Core" HintPath="$(MSBuildBinPath)\Microsoft.Build.Utilities.Core.dll" />
<Reference Include="Xamarin.iOS.Tasks" HintPath="..\..\..\msbuild\Xamarin.iOS.Tasks\bin\$(Configuration)\netstandard2.0\Xamarin.iOS.Tasks.dll" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.11.1" />
<PackageReference Include="NUnit.Extension.NUnitV2ResultWriter" Version="3.6.0" />
</ItemGroup>
<Target Name="BuildTasksAssembly" AfterTargets="BeforeBuild">
<MSBuild Projects="..\..\..\msbuild\Xamarin.iOS.Tasks\Xamarin.iOS.Tasks.csproj" />
</Target>
<ItemGroup>
<!-- Copy system Microsoft.Build*.dll and dependencies for tests to run against. We can remove this
and rely entirely on NuGet assets when mono/msbuild is merged into microsoft/msbuild. -->
<None Include="$(MSBuildToolsPath)\Microsoft.Build*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildToolsPath)\System.*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\tests\common\Configuration.cs">
<Link>Configuration.cs</Link>
</Compile>
<Compile Include="..\..\..\tests\common\DotNet.cs">
<Link>DotNet.cs</Link>
</Compile>
<Compile Include="..\..\..\tests\common\Profile.cs">
<Link>Profile.cs</Link>
</Compile>
<Compile Include="..\..\..\tests\common\ExecutionHelper.cs">
<Link>ExecutionHelper.cs</Link>
</Compile>
<Compile Include="..\..\..\tests\mtouch\Cache.cs">
<Link>Cache.cs</Link>
</Compile>
</ItemGroup>
</Project>

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

@ -20,7 +20,7 @@ namespace Xharness.Jenkins {
public IEnumerator<NUnitExecuteTask> GetEnumerator ()
{
var netstandard2Project = new TestProject (Path.GetFullPath (Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.iOS.Tasks.Tests", "Xamarin.iOS.Tasks.Tests.csproj")));
var netstandard2Project = new TestProject (Path.GetFullPath (Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.MacDev.Tasks.Tests", "Xamarin.MacDev.Tasks.Tests.csproj")));
var buildiOSMSBuild = new MSBuildTask (jenkins: jenkins, testProject: netstandard2Project, processManager: processManager) {
SpecifyPlatform = false,
SpecifyConfiguration = true,
@ -30,17 +30,39 @@ namespace Xharness.Jenkins {
SupportsParallelExecution = false,
};
var nunitExecutioniOSMSBuild = new NUnitExecuteTask (jenkins, buildiOSMSBuild, processManager) {
TestLibrary = Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.iOS.Tasks.Tests", "bin", "Debug", "net461", "Xamarin.iOS.Tasks.Tests.dll"),
TestLibrary = Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.MacDev.Tasks.Tests", "bin", "Debug", "net461", "Xamarin.MacDev.Tasks.Tests.dll"),
TestProject = netstandard2Project,
ProjectConfiguration = "Debug",
Platform = TestPlatform.iOS,
TestName = "MSBuild tests",
Mode = "iOS",
Mode = "iOS (tasks)",
Timeout = TimeSpan.FromMinutes (60),
Ignored = !jenkins.IncludeiOSMSBuild,
SupportsParallelExecution = false,
};
yield return nunitExecutioniOSMSBuild;
var msbuildIntegrationTestsProject = new TestProject (Path.GetFullPath (Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.MacDev.Tests", "Xamarin.MacDev.Tests.csproj")));
var buildiOSMSBuildIntegration = new MSBuildTask (jenkins: jenkins, testProject: msbuildIntegrationTestsProject, 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 nunitExecutioniOSMSBuildIntegration = new NUnitExecuteTask (jenkins, buildiOSMSBuildIntegration, processManager) {
TestLibrary = Path.Combine (HarnessConfiguration.RootDirectory, "msbuild", "Xamarin.MacDev.Tests", "bin", "Debug", "net461", "Xamarin.MacDev.Tests.dll"),
TestProject = msbuildIntegrationTestsProject,
ProjectConfiguration = "Debug",
Platform = TestPlatform.iOS,
TestName = "MSBuild tests",
Mode = "iOS (integration)",
Timeout = TimeSpan.FromMinutes (60),
Ignored = !jenkins.IncludeiOSMSBuild,
SupportsParallelExecution = false,
};
yield return nunitExecutioniOSMSBuildIntegration;
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) {