[Harness] Move BuildToolTask to a more general namespace. (#8287)
Move the task and use composition so that we can reuse the code. This will later allow other projects to use the class without the need of Jenkins or Harness and just implement the base class. Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com> Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com>
This commit is contained in:
Родитель
a6955968fa
Коммит
5b99859321
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
|
|
@ -1,30 +1,40 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.XHarness.iOS.Shared.Execution;
|
||||
|
||||
namespace Xharness.Jenkins.TestTasks
|
||||
{
|
||||
public abstract class BuildToolTask : AppleTestTask
|
||||
{
|
||||
protected readonly IProcessManager ProcessManager;
|
||||
readonly Xharness.TestTasks.BuildToolTask buildToolTask;
|
||||
|
||||
public bool SpecifyPlatform = true;
|
||||
public bool SpecifyConfiguration = true;
|
||||
public IProcessManager ProcessManager => buildToolTask.ProcessManager;
|
||||
|
||||
protected BuildToolTask (IProcessManager processManager)
|
||||
{
|
||||
ProcessManager = processManager ?? throw new ArgumentNullException (nameof (processManager));
|
||||
public bool SpecifyPlatform {
|
||||
get => buildToolTask.SpecifyPlatform;
|
||||
set => buildToolTask.SpecifyPlatform = value;
|
||||
}
|
||||
|
||||
public bool SpecifyConfiguration {
|
||||
get => buildToolTask.SpecifyConfiguration;
|
||||
set => buildToolTask.SpecifyConfiguration = value;
|
||||
}
|
||||
|
||||
protected BuildToolTask (IProcessManager processManager)
|
||||
=> buildToolTask = new Xharness.TestTasks.BuildToolTask (processManager);
|
||||
|
||||
public override TestPlatform Platform {
|
||||
get => base.Platform;
|
||||
set {
|
||||
base.Platform = value;
|
||||
buildToolTask.Platform = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Mode {
|
||||
get { return Platform.ToString (); }
|
||||
set { throw new NotSupportedException (); }
|
||||
get => buildToolTask.Mode;
|
||||
set => buildToolTask.Mode = value;
|
||||
}
|
||||
|
||||
public virtual Task CleanAsync ()
|
||||
{
|
||||
Console.WriteLine ("Clean is not implemented for {0}", GetType ().Name);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public virtual Task CleanAsync () => buildToolTask.CleanAsync ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.XHarness.iOS.Shared;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.XHarness.iOS.Shared.Execution;
|
||||
|
||||
namespace Xharness.TestTasks {
|
||||
|
||||
public class BuildToolTask
|
||||
{
|
||||
public IProcessManager ProcessManager { get; }
|
||||
public TestPlatform Platform { get; set; }
|
||||
|
||||
public bool SpecifyPlatform { get; set; } = true;
|
||||
public bool SpecifyConfiguration { get; set; } = true;
|
||||
|
||||
public BuildToolTask (IProcessManager processManager)
|
||||
{
|
||||
ProcessManager = processManager ?? throw new ArgumentNullException (nameof (processManager));
|
||||
}
|
||||
|
||||
public BuildToolTask (IProcessManager processManager, TestPlatform platform) : this (processManager)
|
||||
{
|
||||
Platform = platform;
|
||||
}
|
||||
|
||||
public virtual string Mode {
|
||||
get { return Platform.ToString (); }
|
||||
set { throw new NotSupportedException (); }
|
||||
}
|
||||
|
||||
public virtual Task CleanAsync ()
|
||||
{
|
||||
Console.WriteLine ("Clean is not implemented for {0}", GetType ().Name);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,7 +37,6 @@ namespace Xharness.TestTasks {
|
|||
protected static string Timestamp => Helpers.Timestamp;
|
||||
public string ProjectFile => TestProject?.Path;
|
||||
public bool HasCustomTestName => test_name != null;
|
||||
public TestPlatform Platform { get; set; }
|
||||
|
||||
public bool NotStarted => (ExecutionResult & TestExecutingResult.StateMask) == TestExecutingResult.NotStarted;
|
||||
public bool InProgress => (ExecutionResult & TestExecutingResult.InProgress) == TestExecutingResult.InProgress;
|
||||
|
@ -138,6 +137,7 @@ namespace Xharness.TestTasks {
|
|||
|
||||
#region Virtual
|
||||
|
||||
public virtual TestPlatform Platform { get; set; }
|
||||
public virtual string ProgressMessage { get; }
|
||||
public virtual string Mode { get; set; }
|
||||
public virtual string Variation { get; set; }
|
||||
|
|
|
@ -120,6 +120,7 @@
|
|||
<Compile Include="TestTasks\IAcquiredResource.cs" />
|
||||
<Compile Include="TestTasks\Resource.cs" />
|
||||
<Compile Include="TestTasks\Resources.cs" />
|
||||
<Compile Include="TestTasks\BuildToolTask.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\tools\common\SdkVersions.cs">
|
||||
|
|
Загрузка…
Ссылка в новой задаче