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

Moving Desktop,& Dotnet runtime providers to separate dll #659

Merged
merged 10 commits into from
Mar 31, 2017
17 changes: 16 additions & 1 deletion TestPlatform.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
VisualStudioVersion = 15.0.26228.9
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED0C35EB-7F31-4841-A24F-8EB708FFA959}"
EndProject
Expand Down Expand Up @@ -147,6 +147,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platform", "Platform", "{37
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.CommunicationUtilities.PlatformTests", "test\Microsoft.TestPlatform.CommunicationUtilities.PlatformTests\Microsoft.TestPlatform.CommunicationUtilities.PlatformTests.csproj", "{3E698655-0701-482E-9AA7-F956F6337FC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.TestHostProvider", "src\Microsoft.TestPlatform.TestHostProvider\Microsoft.TestPlatform.TestHostProvider.csproj", "{F6624DEC-C1F7-4076-8488-93EE30C163C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -757,6 +759,18 @@ Global
{3E698655-0701-482E-9AA7-F956F6337FC7}.Release|x64.Build.0 = Release|Any CPU
{3E698655-0701-482E-9AA7-F956F6337FC7}.Release|x86.ActiveCfg = Release|Any CPU
{3E698655-0701-482E-9AA7-F956F6337FC7}.Release|x86.Build.0 = Release|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Debug|x64.ActiveCfg = Debug|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Debug|x64.Build.0 = Debug|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Debug|x86.ActiveCfg = Debug|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Debug|x86.Build.0 = Debug|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Release|Any CPU.Build.0 = Release|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Release|x64.ActiveCfg = Release|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Release|x64.Build.0 = Release|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Release|x86.ActiveCfg = Release|Any CPU
{F6624DEC-C1F7-4076-8488-93EE30C163C4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -821,5 +835,6 @@ Global
{E141A226-CC0A-4F26-BD17-4AE427D81C3B} = {D27E1CB4-C641-4C6C-A140-EF5F6215AE29}
{376C19DE-31E2-4FF6-88FC-0D0D6233C999} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
{3E698655-0701-482E-9AA7-F956F6337FC7} = {376C19DE-31E2-4FF6-88FC-0D0D6233C999}
{F6624DEC-C1F7-4076-8488-93EE30C163C4} = {ED0C35EB-7F31-4841-A24F-8EB708FFA959}
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ function Publish-Package
Write-Verbose "Move-Item $coreCLR20PackageDir\$file $coreCLRExtensionsDir -Force"
Move-Item $coreCLR20PackageDir\$file $coreCLRExtensionsDir -Force
}

# Note Note: If there are some dependencies for the TestHostProvider assemblies, those need to be moved too.
$runtimeproviders = @("Microsoft.TestPlatform.TestHostProvider.dll", "Microsoft.TestPlatform.TestHostProvider.pdb")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep the name generic? Should the name say that these are NET runtime providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean up

foreach($file in $runtimeproviders) {
Write-Verbose "Move-Item $fullCLRPackageDir\$file $fullCLRExtensionsDir -Force"
Move-Item $fullCLRPackageDir\$file $fullCLRExtensionsDir -Force

Write-Verbose "Move-Item $coreCLR20PackageDir\$file $coreCLRExtensionsDir -Force"
Move-Item $coreCLR20PackageDir\$file $coreCLRExtensionsDir -Force
}

# For libraries that are externally published, copy the output into artifacts. These will be signed and packaged independently.
Copy-PackageItems "Microsoft.TestPlatform.Build"
Expand Down
57 changes: 33 additions & 24 deletions src/Microsoft.TestPlatform.Client/TestPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
namespace Microsoft.VisualStudio.TestPlatform.Client
{
using System;
using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using Microsoft.VisualStudio.TestPlatform.Client.Discovery;
using Microsoft.VisualStudio.TestPlatform.Client.Execution;
using Microsoft.VisualStudio.TestPlatform.Common;
using Microsoft.VisualStudio.TestPlatform.Common.Hosting;
using Microsoft.VisualStudio.TestPlatform.Common.Logging;
using Microsoft.VisualStudio.TestPlatform.Common.Utilities;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine;
Expand All @@ -20,21 +21,21 @@ namespace Microsoft.VisualStudio.TestPlatform.Client
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.Common.Hosting;

/// <summary>
/// Implementation for TestPlatform
/// </summary>
public class TestPlatform : ITestPlatform
{
private IFileHelper fileHelper;
private readonly TestRuntimeProviderManager testHostProviderManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename, maybe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do this in clean up PR. Have to rename lot of variables, & a few classes, & namespaces as well


private readonly IFileHelper fileHelper;

/// <summary>
/// Initializes a new instance of the <see cref="TestPlatform"/> class.
/// </summary>
public TestPlatform() : this(new TestEngine(), new FileHelper())
public TestPlatform() : this(new TestEngine(), new FileHelper(), TestRuntimeProviderManager.Instance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm super confused: Whose responsibility is the TestRuntimeProvider? Not the engine's anymore? How would this look if another engine came in instead of the CrossPlatEngine? Is that even interesting anymore? We might need a doc for this please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The responsibility to provide TestRuntime, is moved to TestRuntimeProviderManager, which for a given session identifies all available TestRuntime, for instance (Desktop, DotNet), & then returns back a particular instance of Runtime, which would work for current settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. And is this tied to the test engine in any way? What happens if a substitute engine wants to provide its own host process as a default?(say TAEF) Is that supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, If Taef wants to be the test runtime(i.e replace testhost), then they can provide their runtime whose job is to understand how to launch TAEF, once that is discovered, Taef can continue to host our crossplat engine to do the communication, & running test work, or they can implement their own communication framework which understands the protocol send across wire.

{
this.testHostProviderManager = TestRuntimeProviderManager.Instance;
}

/// <summary>
Expand All @@ -43,19 +44,24 @@ public class TestPlatform : ITestPlatform
/// <param name="testEngine">
/// The test engine.
/// </param>
protected TestPlatform(ITestEngine testEngine, IFileHelper filehelper)
/// <param name="filehelper">
/// The filehelper.
/// </param>
/// <param name="testHostProviderManager">
/// The data.
/// </param>
internal TestPlatform(ITestEngine testEngine, IFileHelper filehelper, TestRuntimeProviderManager testHostProviderManager)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not protected? We already use the Testable approach for the unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

{
this.TestEngine = testEngine;
this.fileHelper = filehelper;
this.testHostProviderManager = testHostProviderManager;
}

/// <summary>
/// Gets or sets Test Engine instance
/// </summary>
private ITestEngine TestEngine { get; set; }

private TestRuntimeProviderManager testHostProviderManager;

/// <summary>
/// The create discovery request.
/// </summary>
Expand All @@ -66,16 +72,13 @@ public IDiscoveryRequest CreateDiscoveryRequest(DiscoveryCriteria discoveryCrite
{
if (discoveryCriteria == null)
{
throw new ArgumentNullException("discoveryCriteria");
throw new ArgumentNullException(nameof(discoveryCriteria));
}

UpdateTestAdapterPaths(discoveryCriteria.RunSettings);
this.UpdateTestAdapterPaths(discoveryCriteria.RunSettings);

var runconfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(discoveryCriteria.RunSettings);
//var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(runconfiguration);
var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(discoveryCriteria.RunSettings);

var testHostManager = this.TestEngine.GetDefaultTestHostManager(runconfiguration);

var discoveryManager = this.TestEngine.GetDiscoveryManager(testHostManager, discoveryCriteria);
discoveryManager.Initialize();

Expand All @@ -92,26 +95,24 @@ public ITestRunRequest CreateTestRunRequest(TestRunCriteria testRunCriteria)
{
if (testRunCriteria == null)
{
throw new ArgumentNullException("testRunCriteria");
throw new ArgumentNullException(nameof(testRunCriteria));
}

UpdateTestAdapterPaths(testRunCriteria.TestRunSettings);
this.UpdateTestAdapterPaths(testRunCriteria.TestRunSettings);

var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings);

//var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(runConfiguration);

// Update and initialize loggers only when DesignMode is false
if (runConfiguration.DesignMode == false)
{
UpdateTestLoggerPath(testRunCriteria);
this.UpdateTestLoggerPath(testRunCriteria);

// Initialize loggers
TestLoggerManager.Instance.InitializeLoggers();
}

var testHostManager = this.TestEngine.GetDefaultTestHostManager(runConfiguration);
testHostManager.Initialize(TestSessionMessageLogger.Instance);
var testHostManager = this.testHostProviderManager.GetTestHostManagerByRunConfiguration(testRunCriteria.TestRunSettings);
testHostManager.Initialize(TestSessionMessageLogger.Instance, testRunCriteria.TestRunSettings);

if (testRunCriteria.TestHostLauncher != null)
{
Expand Down Expand Up @@ -159,6 +160,9 @@ public void UpdateExtensions(IEnumerable<string> pathToAdditionalExtensions, boo
/// <summary>
/// Update the test adapter paths provided through run settings to be used by the test service
/// </summary>
/// <param name="runSettings">
/// The run Settings.
/// </param>
private void UpdateTestAdapterPaths(string runSettings)
{
IEnumerable<string> customTestAdaptersPaths = RunSettingsUtilities.GetTestAdaptersPaths(runSettings);
Expand All @@ -175,8 +179,10 @@ private void UpdateTestAdapterPaths(string runSettings)
}

List<string> adapterFiles = new List<string>(
this.fileHelper.EnumerateFiles(adapterPath, TestPlatformConstants.TestAdapterRegexPattern, SearchOption.AllDirectories)
);
this.fileHelper.EnumerateFiles(
adapterPath,
TestPlatformConstants.TestAdapterRegexPattern,
SearchOption.AllDirectories));
if (adapterFiles.Count > 0)
{
this.UpdateExtensions(adapterFiles, true);
Expand All @@ -188,6 +194,9 @@ private void UpdateTestAdapterPaths(string runSettings)
/// <summary>
/// Update the test logger paths from source directory
/// </summary>
/// <param name="testRunCriteria">
/// The test Run Criteria.
/// </param>
private void UpdateTestLoggerPath(TestRunCriteria testRunCriteria)
{
IEnumerable<string> sources = testRunCriteria.Sources;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.TestPlatform.Common/Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
[assembly: InternalsVisibleTo("datacollector.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
[assembly: InternalsVisibleTo("Microsoft.TestPlatform.CommunicationUtilities.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]

[assembly: InternalsVisibleTo("Microsoft.TestPlatform.Client.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]

#endregion
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting
{
using System.Collections.Generic;

using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework;
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities;
using Microsoft.VisualStudio.TestPlatform.Common.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using System.Collections.Generic;

/// <summary>
/// Manages loading and provides access to testhost extensions implementing the
Expand All @@ -17,6 +18,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting
internal class TestRuntimeExtensionManager : TestExtensionManager<ITestRuntimeProvider, ITestRuntimeCapabilities>
{
/// <summary>
/// Initializes a new instance of the <see cref="TestRuntimeExtensionManager"/> class.
/// Default constructor.
/// </summary>
/// <param name="unfilteredTestExtensions">
Expand Down Expand Up @@ -60,5 +62,4 @@ public static TestRuntimeExtensionManager Create(IMessageLogger messageLogger)
return new TestRuntimeExtensionManager(unfilteredTestExtensions, filteredTestExtensions, messageLogger);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
namespace Microsoft.VisualStudio.TestPlatform.Common.Hosting
{
using System;

using Microsoft.VisualStudio.TestPlatform.Common.Logging;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.Common.Logging;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;

/// <summary>
/// Responsible for managing TestRuntimeProviderManager extensions
Expand All @@ -18,45 +18,29 @@ internal class TestRuntimeProviderManager

private static TestRuntimeProviderManager testHostManager;

/// <summary>
/// Gets an instance of the logger.
/// </summary>
private IMessageLogger messageLogger;
private readonly TestRuntimeExtensionManager testHostExtensionManager;

private TestRuntimeExtensionManager testHostExtensionManager;

#endregion

#region Constructor

/// <summary>
/// Initializes a new instance of the <see cref="TestRuntimeProviderManager"/> class.
/// Default constructor.
/// </summary>
protected TestRuntimeProviderManager(TestSessionMessageLogger sessionLogger)
/// <param name="sessionLogger">
/// The session Logger.
/// </param>
protected TestRuntimeProviderManager(IMessageLogger sessionLogger)
{
this.messageLogger = sessionLogger;
this.testHostExtensionManager = TestRuntimeExtensionManager.Create(sessionLogger);
}

/// <summary>
/// Gets the instance.
/// Gets the instance of TestRuntimeProviderManager
/// </summary>
public static TestRuntimeProviderManager Instance
{
get
{
if (testHostManager == null)
{
testHostManager = new TestRuntimeProviderManager(TestSessionMessageLogger.Instance);
}
return testHostManager;
}

protected set
{
testHostManager = value;
}
}
public static TestRuntimeProviderManager Instance => testHostManager
?? (testHostManager = new TestRuntimeProviderManager(TestSessionMessageLogger.Instance));

#endregion

Expand All @@ -65,21 +49,17 @@ protected set
public ITestRuntimeProvider GetTestHostManagerByUri(string hostUri)
{
var host = this.testHostExtensionManager.TryGetTestExtension(hostUri);
if (host != null)
{
return host.Value;
}

return null;
return host?.Value;
}

public ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration)
public virtual ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration)
{
foreach (var testExtension in this.testHostExtensionManager.TestExtensions)
{
if (testExtension.Value.CanExecuteCurrentRunConfiguration(runConfiguration))
{
return testExtension.Value;
// we are creating a new Instance of ITestRuntimeProvider so that each POM gets it's own object of ITestRuntimeProvider
return (ITestRuntimeProvider)Activator.CreateInstance(testExtension.Value.GetType());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ public interface ITestEngine
/// <summary>
/// Fetches the DiscoveryManager for this engine. This manager would provide all functionality required for discovery.
/// </summary>
/// <param name="testHostManager">Test host manager for the current test discovery.</param>
/// <returns>ITestDiscoveryManager object that can do discovery</returns>
/// <param name="testHostManager">
/// Test host manager for the current test discovery.
/// </param>
/// <param name="discoveryCriteria">
/// The discovery Criteria.
/// </param>
/// <returns>
/// ITestDiscoveryManager object that can do discovery
/// </returns>
IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostManager, DiscoveryCriteria discoveryCriteria);

/// <summary>
Expand All @@ -37,8 +44,8 @@ public interface ITestEngine
/// Fetches the Test Host manager for this engine. This manager would provide extensibility
/// features that this engine supports.
/// </summary>
/// <param name="runConfiguration">RunConfiguration information which contains info like Architecture, Framework for the test run.</param>
/// <param name="runSettingsXml">runSettingsXml information which contains info like Architecture, Framework for the test run.</param>
/// <returns>Launcher for the test host process</returns>
ITestRuntimeProvider GetDefaultTestHostManager(RunConfiguration runConfiguration);
ITestRuntimeProvider GetDefaultTestHostManager(string runSettingsXml);
}
}
Loading