[CI] Allow to ignore tests if dotnet is enabled. (#11604)

This commit is contained in:
Manuel de la Pena 2021-05-20 09:37:22 -04:00 коммит произвёл GitHub
Родитель 52c75d30b4
Коммит 8ec9182b12
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 31 добавлений и 1 удалений

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

@ -108,6 +108,7 @@ test.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk
@echo "WATCH_SDK_VERSION=$(WATCH_SDK_VERSION)" >> $@
@echo "OSX_SDK_VERSION=$(OSX_SDK_VERSION)" >> $@
@echo "DOTNET6_BCL_DIR=$(DOTNET6_BCL_DIR)" >> $@
@echo "ENABLE_DOTNET=$(ENABLE_DOTNET)" >> $@
test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk
@rm -f $@

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

@ -42,6 +42,7 @@ namespace Xamarin.Tests
public static bool include_dotnet_watchos;
public static bool include_maccatalyst;
public static bool include_device;
public static bool include_dotnet;
static Version xcode_version;
public static Version XcodeVersion {
@ -270,6 +271,7 @@ namespace Xamarin.Tests
include_dotnet_watchos = !string.IsNullOrEmpty (GetVariable ("INCLUDE_DOTNET_WATCH", ""));
include_maccatalyst = !string.IsNullOrEmpty (GetVariable ("INCLUDE_MACCATALYST", ""));
include_device = !string.IsNullOrEmpty (GetVariable ("INCLUDE_DEVICE", ""));
include_dotnet = !string.IsNullOrEmpty (GetVariable ("ENABLE_DOTNET", ""));
DotNet6BclDir = GetVariable ("DOTNET6_BCL_DIR", null);
XcodeVersionString = GetXcodeVersion (xcode_root);
@ -294,6 +296,7 @@ namespace Xamarin.Tests
Console.WriteLine (" INCLUDE_TVOS={0}", include_tvos);
Console.WriteLine (" INCLUDE_WATCHOS={0}", include_watchos);
Console.WriteLine (" INCLUDE_MACCATALYST={0}", include_maccatalyst);
Console.WriteLine (" ENABLE_DOTNET={0}", include_dotnet);
}
public static string RootPath {
@ -700,6 +703,13 @@ namespace Xamarin.Tests
Assert.Ignore ("This build does not include device support.");
}
public static void AssertDotNetAvailable ()
{
if (include_dotnet)
return;
Assert.Ignore (".NET tests not enabled");
}
public static string CloneTestDirectory (string directory)
{
// Copy the test projects to a temporary directory so that we can run the tests from there without affecting the working directory.

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

@ -51,6 +51,8 @@ namespace Xamarin.iOS.Tasks {
[TestCase ("MyXamarinFormsApp")]
public void CompareBuilds (string project, int expectedErrorCount = 0)
{
Configuration.AssertDotNetAvailable ();
tfi = "Xamarin.iOS";
switch (project) {
case "MyMetalGame":

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

@ -132,6 +132,7 @@ namespace Xharness {
public string MONO_IOS_SDK_DESTDIR { get; }
public string MONO_MAC_SDK_DESTDIR { get; }
public bool ENABLE_XAMARIN { get; }
public bool ENABLE_DOTNET { get; }
// Run
@ -203,6 +204,7 @@ namespace Xharness {
MONO_IOS_SDK_DESTDIR = config ["MONO_IOS_SDK_DESTDIR"];
MONO_MAC_SDK_DESTDIR = config ["MONO_MAC_SDK_DESTDIR"];
ENABLE_XAMARIN = config.ContainsKey ("ENABLE_XAMARIN") && !string.IsNullOrEmpty (config ["ENABLE_XAMARIN"]);
ENABLE_DOTNET = config.ContainsKey ("ENABLE_DOTNET") && !string.IsNullOrEmpty (config ["ENABLE_DOTNET"]);
if (string.IsNullOrEmpty (SdkRoot))
SdkRoot = config ["XCODE_DEVELOPER_ROOT"] ?? configuration.SdkRoot;

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

@ -43,6 +43,7 @@ namespace Xharness {
string MONO_IOS_SDK_DESTDIR { get; }
string MONO_MAC_SDK_DESTDIR { get; }
bool ENABLE_XAMARIN { get; }
bool ENABLE_DOTNET { get; }
string XcodeRoot { get; }
string LogDirectory { get; }
double Timeout { get; }

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

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;

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

@ -327,6 +327,11 @@ namespace Xharness.Jenkins {
MainLog.WriteLine ("The macOS build is disabled, so any macOS tests will be disabled as well.");
jenkins.IncludeMac = false;
}
if (!Harness.ENABLE_DOTNET) {
MainLog.WriteLine ("The .NET build is disabled, so any .NET tests will be disabled as well.");
jenkins.IncludeDotNet = false;
}
}
}
}

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

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.Common.Execution;
using Microsoft.DotNet.XHarness.Common.Logging;
@ -14,6 +15,7 @@ namespace Xharness.Jenkins.TestTasks {
public bool SpecifyPlatform { get; set; } = true;
public bool SpecifyConfiguration { get; set; } = true;
public List<string> Constants { get; } = new List<string> ();
public BuildTool (IProcessManager processManager)
{

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

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.DotNet.XHarness.Common.Execution;
using Microsoft.DotNet.XHarness.Common.Logging;
@ -33,6 +34,10 @@ namespace Xharness.Jenkins.TestTasks {
set => buildToolTask.SpecifyConfiguration = value;
}
public List<string> Constants {
get => buildToolTask.Constants;
}
public override TestProject TestProject {
get => base.TestProject;
set {

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

@ -32,6 +32,8 @@ namespace Xharness.Jenkins.TestTasks {
if (Platform == TestPlatform.MacCatalyst)
args.Add ("/r");
args.Add (projectFile);
if (Constants.Count > 0)
args.Add($"/p:DefineConstants=\"{string.Join(";", Constants)}\"");
return args;
}