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

Filtering non existent adapter paths #1578

Merged
merged 2 commits into from
May 8, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;

/// <summary>
/// Orchestrates discovery operations for the engine communicating with the client.
Expand All @@ -31,6 +33,7 @@ public class ProxyDiscoveryManager : ProxyOperationManager, IProxyDiscoveryManag
private IRequestData requestData;
private ITestDiscoveryEventsHandler2 baseTestDiscoveryEventsHandler;
private bool skipDefaultAdapters;
private readonly IFileHelper fileHelper;

#region Constructors

Expand All @@ -41,7 +44,7 @@ public class ProxyDiscoveryManager : ProxyOperationManager, IProxyDiscoveryManag
/// <param name="testRequestSender">Test request sender instance.</param>
/// <param name="testHostManager">Test host manager instance.</param>
public ProxyDiscoveryManager(IRequestData requestData, ITestRequestSender testRequestSender, ITestRuntimeProvider testHostManager)
: this(requestData, testRequestSender, testHostManager, JsonDataSerializer.Instance)
: this(requestData, testRequestSender, testHostManager, JsonDataSerializer.Instance, new FileHelper())
{
this.testHostManager = testHostManager;
}
Expand All @@ -61,13 +64,15 @@ public ProxyDiscoveryManager(IRequestData requestData, ITestRequestSender testRe
internal ProxyDiscoveryManager(IRequestData requestData,
ITestRequestSender requestSender,
ITestRuntimeProvider testHostManager,
IDataSerializer dataSerializer)
IDataSerializer dataSerializer,
IFileHelper fileHelper)
: base(requestData, requestSender, testHostManager)
{
this.dataSerializer = dataSerializer;
this.testHostManager = testHostManager;
this.isCommunicationEstablished = false;
this.requestData = requestData;
this.fileHelper = fileHelper;
}

#endregion
Expand Down Expand Up @@ -173,14 +178,33 @@ public void HandleLogMessage(TestMessageLevel level, string message)
private void InitializeExtensions(IEnumerable<string> sources)
{
var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, this.skipDefaultAdapters);

// Filter out non existing extensions
var nonExistingExtensions = extensions.Where(extension => !this.fileHelper.Exists(extension));
if (nonExistingExtensions.Any())
{
this.LogMessage(TestMessageLevel.Warning, string.Format(Resources.Resources.NonExistingExtensions, string.Join(",", nonExistingExtensions)));
}

var sourceList = sources.ToList();
var platformExtensions = this.testHostManager.GetTestPlatformExtensions(sourceList, extensions).ToList();
var platformExtensions = this.testHostManager.GetTestPlatformExtensions(sourceList, extensions.Except(nonExistingExtensions));

// Only send this if needed.
if (platformExtensions.Any())
{
this.RequestSender.InitializeDiscovery(platformExtensions);
}
}

private void LogMessage(TestMessageLevel testMessageLevel, string message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate code in PEM, & PDM, can we move this to POM

{
// Log to translation layer.
var testMessagePayload = new TestMessagePayload { MessageLevel = testMessageLevel, Message = message };
var rawMessage = this.dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload);
this.HandleRawMessage(rawMessage);

// Log to vstest.console layer.
this.HandleLogMessage(testMessageLevel, message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;

/// <summary>
/// Orchestrates test execution operations for the engine communicating with the client.
Expand All @@ -33,6 +35,7 @@ internal class ProxyExecutionManager : ProxyOperationManager, IProxyExecutionMan
private IRequestData requestData;
private ITestRunEventsHandler baseTestRunEventsHandler;
private bool skipDefaultAdapters;
private readonly IFileHelper fileHelper;

/// <inheritdoc/>
public bool IsInitialized { get; private set; } = false;
Expand All @@ -46,7 +49,7 @@ internal class ProxyExecutionManager : ProxyOperationManager, IProxyExecutionMan
/// <param name="requestSender">Test request sender instance.</param>
/// <param name="testHostManager">Test host manager for this proxy.</param>
public ProxyExecutionManager(IRequestData requestData, ITestRequestSender requestSender, ITestRuntimeProvider testHostManager) :
this(requestData, requestSender, testHostManager, JsonDataSerializer.Instance)
this(requestData, requestSender, testHostManager, JsonDataSerializer.Instance, new FileHelper())
{
}

Expand All @@ -59,13 +62,14 @@ public ProxyExecutionManager(IRequestData requestData, ITestRequestSender reques
/// <param name="testHostManager">Test host manager instance</param>
/// <param name="dataSerializer"></param>
internal ProxyExecutionManager(IRequestData requestData, ITestRequestSender requestSender,
ITestRuntimeProvider testHostManager, IDataSerializer dataSerializer)
ITestRuntimeProvider testHostManager, IDataSerializer dataSerializer, IFileHelper fileHelper)
: base(requestData, requestSender, testHostManager)
{
this.testHostManager = testHostManager;
this.dataSerializer = dataSerializer;
this.isCommunicationEstablished = false;
this.requestData = requestData;
this.fileHelper = fileHelper;
}

#endregion
Expand Down Expand Up @@ -260,8 +264,16 @@ private void LogMessage(TestMessageLevel testMessageLevel, string message)
private void InitializeExtensions(IEnumerable<string> sources)
{
var extensions = TestPluginCache.Instance.GetExtensionPaths(TestPlatformConstants.TestAdapterEndsWithPattern, this.skipDefaultAdapters);

// Filter out non existing extensions
var nonExistingExtensions = extensions.Where(extension => !this.fileHelper.Exists(extension));
if (nonExistingExtensions.Any())
{
this.LogMessage(TestMessageLevel.Warning, string.Format(Resources.Resources.NonExistingExtensions, string.Join(",", nonExistingExtensions)));
}

var sourceList = sources.ToList();
var platformExtensions = this.testHostManager.GetTestPlatformExtensions(sourceList, extensions).ToList();
var platformExtensions = this.testHostManager.GetTestPlatformExtensions(sourceList, extensions.Except(nonExistingExtensions));

// Only send this if needed.
if (platformExtensions.Any())
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,7 @@
<data name="OldTestHostIsGettingUsed" xml:space="preserve">
<value>You are using an older version of Microsoft.NET.Test.Sdk. Kindly move to a version equal or greater than 15.3.0.</value>
</data>
<data name="NonExistingExtensions" xml:space="preserve">
<value>Could not find extensions: {0}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Používáte starší verzi sady Microsoft.NET.Test.Sdk. Přejděte prosím na verzi 15.3.0 nebo vyšší.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Sie verwenden eine ältere Version von Microsoft.NET.Test.Sdk. Wechseln Sie zu Version 15.3.0 oder höher.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Está utilizando una versión anterior de Microsoft.NET.Test.Sdk. Cámbiese a una versión igual o superior a 15.3.0.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Vous utilisez une ancienne version de Microsoft.NET.Test.Sdk. Passez à une version égale ou supérieure à la version 15.3.0.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">La versione di Microsoft.NET.Test.Sdk è obsoleta. Passare alla versione 15.3.0 o a una versione successiva.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Microsoft.NET.Test.Sdk の古いバージョンを使用しています。15.3.0 以降のバージョンに移行することをお勧めします。</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">이전 버전의 Microsoft.NET.Test.Sdk를 사용하고 있습니다. 15.3.0 이상 버전으로 이동하세요.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Używamy starszej wersji zestawu Microsoft.NET.Test.Sdk. Przejdź na wersję 15.3.0 lub nowszą.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Você está usando uma versão mais antiga do Microsoft.NET.Test.Sdk. Mude para uma versão igual ou maior que 15.3.0.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Вы используете более старую версию Microsoft.NET.Test.Sdk. Перейдите на версию 15.3.0 или более позднюю.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">Eski bir Microsoft.NET.Test.Sdk sürümü kullanıyorsunuz. Lütfen 15.3.0 veya daha yeni bir sürüme geçin.</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
<target state="new">You are using an older version of Microsoft.NET.Test.Sdk. Kindly move to a version equal or greater than 15.3.0</target>
<note></note>
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">你使用的是旧版 Microsoft.NET.Test.Sdk。请迁移到 15.3.0 及更高版本。</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
<target state="translated">您正使用較舊版的 Microsoft.NET.Test.Sdk。請移到等於或大於 15.3.0 的版本。</target>
<note />
</trans-unit>
<trans-unit id="NonExistingExtensions">
<source>Could not find extensions: {0}</source>
<target state="new">Could not find extensions: {0}</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Collections.Generic;
Expand All @@ -29,13 +30,15 @@ public class ProxyBaseManagerTests
protected readonly Mock<ITestRuntimeProvider> mockTestHostManager;
protected Mock<IDataSerializer> mockDataSerializer;
protected Mock<ICommunicationChannel> mockChannel;
private Mock<IFileHelper> mockFileHelper;

public ProxyBaseManagerTests()
{
this.mockTestHostManager = new Mock<ITestRuntimeProvider>();
this.mockDataSerializer = new Mock<IDataSerializer>();
this.mockRequestData = new Mock<IRequestData>();
this.mockChannel = new Mock<ICommunicationChannel>();
this.mockFileHelper = new Mock<IFileHelper>();

this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new Mock<IMetricsCollection>().Object);
this.mockDataSerializer.Setup(mds => mds.DeserializeMessage(null)).Returns(new Message());
Expand Down Expand Up @@ -103,16 +106,18 @@ protected ProxyDiscoveryManager GetProxyDiscoveryManager()
mockRequestData.Object,
testRequestSender,
mockTestHostManager.Object,
mockDataSerializer.Object);
mockDataSerializer.Object,
this.mockFileHelper.Object);

return testDiscoveryManager;
}

internal ProxyExecutionManager GetProxyExecutionManager()
{
this.SetupAndInitializeTestRequestSender();
this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny<string>())).Returns(true);
var testExecutionManager = new ProxyExecutionManager(mockRequestData.Object, testRequestSender,
mockTestHostManager.Object, mockDataSerializer.Object);
mockTestHostManager.Object, mockDataSerializer.Object, this.mockFileHelper.Object);

return testExecutionManager;
}
Expand Down
Loading