Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Harness] Merge the Generator and the Factory in a same object and rename namespace. #8222

Merged
merged 8 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
406 changes: 406 additions & 0 deletions tests/xharness/BCLTestImportTargetFactory.cs

Large diffs are not rendered by default.

84 changes: 0 additions & 84 deletions tests/xharness/BCLTestImporter/BCLTestImportTargetFactory.cs

This file was deleted.

18 changes: 8 additions & 10 deletions tests/xharness/Harness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
using System.IO;
using System.Linq;
using System.Xml;
using Xharness.BCLTestImporter;
using Xharness.TestImporter;
using Xharness.Logging;
using Xharness.Execution;
using Xharness.Targets;
using Xharness.Utilities;
using Xharness.Hardware;
using Xharness.Listeners;

namespace Xharness
{
public enum HarnessAction
{
namespace Xharness {
public enum HarnessAction {
None,
Configure,
Run,
Expand Down Expand Up @@ -196,7 +194,7 @@ public Harness (IResultParser resultParser, HarnessAction action, HarnessConfigu
EnvironmentVariables = new Dictionary<string, string> (configuration.EnvironmentVariables);

LaunchTimeout = InCI ? 3 : 120;

var config = ParseConfigFiles ();
var src_root = Path.GetDirectoryName (Path.GetFullPath (RootDirectory));

Expand All @@ -217,7 +215,7 @@ public Harness (IResultParser resultParser, HarnessAction action, HarnessConfigu

if (string.IsNullOrEmpty (SdkRoot))
SdkRoot = config ["XCODE_DEVELOPER_ROOT"] ?? configuration.SdkRoot;

processManager = new ProcessManager (XcodeRoot, MlaunchPath);
}

Expand Down Expand Up @@ -353,7 +351,7 @@ int AutoConfigureMac (bool generate_projects)
configureTarget (target, file, proj.IsNUnitProject, false);
unified_targets.Add (target);

var cloned_project = (MacTestProject) proj.Clone ();
var cloned_project = (MacTestProject)proj.Clone ();
cloned_project.TargetFrameworkFlavors = MacFlavors.Full;
cloned_project.Path = target.ProjectPath;
MacTestProjects.Add (cloned_project);
Expand All @@ -365,7 +363,7 @@ int AutoConfigureMac (bool generate_projects)
configureTarget (target, file, proj.IsNUnitProject, false);
unified_targets.Add (target);

var cloned_project = (MacTestProject) proj.Clone ();
var cloned_project = (MacTestProject)proj.Clone ();
cloned_project.TargetFrameworkFlavors = MacFlavors.System;
cloned_project.Path = target.ProjectPath;
MacTestProjects.Add (cloned_project);
Expand Down Expand Up @@ -449,7 +447,7 @@ Dictionary<string, string> ParseConfigFiles ()
return configuration;
}

IEnumerable <string> GetConfigFiles ()
IEnumerable<string> GetConfigFiles ()
{
return FindConfigFiles (useSystemXamarinIOSMac ? "test-system.config" : "test.config")
.Concat (FindConfigFiles ("Make.config"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using System.Threading.Tasks;

namespace Xharness.BCLTestImporter {
namespace Xharness.TestImporter {
/// <summary>
/// Class that knows how to generate the plist of a test project.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using Xharness.BCLTestImporter.Templates;

namespace Xharness.BCLTestImporter {
namespace Xharness.TestImporter {
/// <summary>
/// Class that defines a bcl test project. A bcl test project by definition is the combination of the name
/// of the project and a set on assemblies to be tested.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace Xharness.BCLTestImporter {
namespace Xharness.TestImporter {

// interface that will help locate the test assemblies that are used to create the apps. This way, we can
// point to a specific location from which the asseblies well be referenced. The idea is to allow to download
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Xharness.BCLTestImporter.Templates;

namespace Xharness.BCLTestImporter {
namespace Xharness.TestImporter {

// factory that hides the creation of the ITestAssemblyDefinition to hide the concreate class that is used by the
// template.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Xharness.BCLTestImporter {
namespace Xharness.TestImporter {
/// <summary>
/// Represents the supported platforms to which we can create projects.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;

namespace Xharness.BCLTestImporter.Templates {
namespace Xharness.TestImporter.Templates {

/// <summary>
/// There are cases in which projects are ignored in certain platforms, either because
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace Xharness.BCLTestImporter.Templates {
namespace Xharness.TestImporter.Templates {

// less typing
public class GeneratedProjects : List<(string Name, string Path, bool XUnit, string ExtraArgs, string Failure, double TimeoutMultiplier)> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Xharness.BCLTestImporter.Templates.Managed {
namespace Xharness.TestImporter.Templates.Managed {
public static class RegisterTypeGenerator {

static readonly string UsingReplacement = "%USING%";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;

namespace Xharness.BCLTestImporter.Templates.Managed {
namespace Xharness.TestImporter.Templates.Managed {

// template project that uses the Xamarin.iOS and Xamarin.Mac frameworks
// to create a testing application for given xunit and nunit test assemblies
Expand All @@ -26,7 +26,7 @@ public class XamariniOSTemplate : ITemplatedProject {
internal static readonly string DownloadPathKey = "%DOWNLOAD PATH%";

// resource related static vars used to copy the embedded src to the hd
static string srcResourcePrefix = "Xharness.BCLTestImporter.Templates.Managed.Resources.src.";
static string srcResourcePrefix = "Xharness.TestImporter.Templates.Managed.Resources.src.";
static string registerTemplateResourceName = "RegisterType.cs";
static string [] [] srcDirectories = new [] {
new [] { "common", },
Expand Down Expand Up @@ -80,7 +80,7 @@ public class XamariniOSTemplate : ITemplatedProject {
public string OutputDirectoryPath { get; set; }
string GeneratedCodePathRoot => Path.Combine (OutputDirectoryPath, "generated");
public string IgnoreFilesRootDirectory { get; set; }
public IAssemblyLocator AssemblyLocator { get; set; }
public IAssemblyLocator AssemblyLocator { get; set; }
public IProjectFilter ProjectFilter { get; set; }
public ITestAssemblyDefinitionFactory AssemblyDefinitionFactory { get; set; }

Expand Down Expand Up @@ -643,7 +643,7 @@ async Task<GeneratedProjects> GenerateMacTestProjectsAsync (IEnumerable<(string
Directory.CreateDirectory (generatedCodeDir);
var registerTypePath = Path.Combine (generatedCodeDir, "RegisterType-mac.cs");

var typesPerAssembly = projectDefinition.GetTypeForAssemblies (AssemblyLocator.GetAssembliesRootLocation (platform), platform);
var typesPerAssembly = projectDefinition.GetTypeForAssemblies (AssemblyLocator.GetAssembliesRootLocation (platform), platform);
var registerCode = await RegisterTypeGenerator.GenerateCodeAsync (typesPerAssembly,
projectDefinition.IsXUnit, GetRegisterTypeTemplate ());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using Xharness.BCLTestImporter.Templates;

namespace Xharness.BCLTestImporter.Xamarin {
namespace Xharness.TestImporter.Xamarin {
public class AssemblyDefinitionFactory : ITestAssemblyDefinitionFactory {
public ITestAssemblyDefinition Create (string assembly, IAssemblyLocator loader) => new TestAssemblyDefinition (assembly, loader);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using Xharness.BCLTestImporter.Templates;

namespace Xharness.BCLTestImporter.Xamarin {
namespace Xharness.TestImporter.Xamarin {

/// <summary>
/// Implemenation of the assembly locator that will return the root path of the mono bcl artifact.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xharness.BCLTestImporter.Templates;
using Xharness.TestImporter.Templates;

namespace Xharness.BCLTestImporter.Xamarin {
namespace Xharness.TestImporter.Xamarin {
public class ProjectFilter : IProjectFilter {

static readonly string splitPattern = ".part";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using Xharness.BCLTestImporter.Templates;

namespace Xharness.BCLTestImporter.Xamarin {
namespace Xharness.TestImporter.Xamarin {
public class TestAssemblyDefinition : ITestAssemblyDefinition{

#region properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using NUnit.Framework;

using System.Threading.Tasks;
using Xharness.BCLTestImporter;
using Xharness.TestImporter;

namespace Xharness.Tests.BCLTestImporter.Tests {
namespace Xharness.Tests.TestImporter.Tests {
public class BCLTestInfoPlistGeneratorTest {

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using Xharness.BCLTestImporter;
using Xharness.BCLTestImporter.Templates;
using Xharness.BCLTestImporter.Xamarin;
using Xharness.TestImporter;
using Xharness.TestImporter.Templates;
using Xharness.TestImporter.Xamarin;

namespace Xharness.Tests.BCLTestImporter.Tests {
namespace Xharness.Tests.TestImporter.Tests {


// test the class so that we ensure that we do call the template object and that we are correctly creating the
Expand All @@ -18,7 +18,7 @@ public class BCLTestProjectGeneratorTest
string outputdir;
AssemblyLocator assemblyLocator;
Mock<ITemplatedProject> template;
BCLTestProjectGenerator generator;
BCLTestImportTargetFactory generator;

[SetUp]
public void SetUp ()
Expand All @@ -28,7 +28,7 @@ public void SetUp ()
Directory.CreateDirectory (outputdir);
assemblyLocator = new AssemblyLocator ();
template = new Mock<ITemplatedProject> ();
generator = new BCLTestProjectGenerator (outputdir) {
generator = new BCLTestImportTargetFactory (outputdir) {
AssemblyLocator = assemblyLocator,
TemplatedProject = template.Object
};
Expand All @@ -45,13 +45,13 @@ public void TearDown ()
[Test]
public void ConstructorNullOutputDir ()
{
Assert.Throws<ArgumentNullException> (() => new BCLTestProjectGenerator (null));
Assert.Throws<ArgumentNullException> (() => new BCLTestProjectGenerator (null, ""));
Assert.Throws<ArgumentNullException> (() => new BCLTestImportTargetFactory ((string) null));
Assert.Throws<ArgumentNullException> (() => new BCLTestImportTargetFactory (null, ""));
}

[Test]
public void ConstructorNullMonoDir () =>
Assert.Throws<ArgumentNullException> (() => new BCLTestProjectGenerator ("", null));
Assert.Throws<ArgumentNullException> (() => new BCLTestImportTargetFactory ("", null));

[Test]
public void iOSMonoSDKPathGetterTest ()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.IO;
using Moq;
using NUnit.Framework;
using Xharness.BCLTestImporter;
using Xharness.BCLTestImporter.Templates;
using Xharness.BCLTestImporter.Xamarin;
using Xharness.TestImporter;
using Xharness.TestImporter.Xamarin;

namespace Xharness.Tests.BCLTestImporter.Tests {
namespace Xharness.Tests.TestImporter.Tests {
public class TestAssemblyDefinitionTest {

Mock<IAssemblyLocator> assemblyLocator;
Expand Down
Loading