Skip to content

Commit

Permalink
Adapter Failed to Load #958 (#2156)
Browse files Browse the repository at this point in the history
* committing changes for #958 fix

* committing changes for #958 fix

* committing tests fixes #958

* commtting fixes for tests #958

* Updated handle class name and downgraded TestMessageLevel Error to Warning

* commit changes to print specific error messages in each case of adapter load fail

* committing new tests for #958

* Code changes refined #958

* LogWarningOnNoTestsDiscovered change reverted

* commit changes improve test results

* commit latest changes

* commtting latest changes

* Reverted TestRunMessage handler unsubscription

* Unsubscribed testRunMessage session

* latest changes

* Amendments have been done

* Format corrected
  • Loading branch information
DineshChirnanchu authored and mayankbansal018 committed Sep 25, 2019
1 parent 462d367 commit 33a2be6
Show file tree
Hide file tree
Showing 32 changed files with 288 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.TestPlatform.Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class TestPlatformDefaults
/// string in the vstest.console.exe.config that specifies the bound on no of jobs in the job queue.
/// </summary>
public const string MaxNumberOfEventsLoggerEventQueueCanHold = "MaxNumberOfEventsLoggerEventQueueCanHold";

/// <summary>
/// Default bound on the job queue.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;

using System.Xml;
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities;
using Microsoft.VisualStudio.TestPlatform.Common.Logging;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources;

/// <summary>
/// Discovers test extensions in a directory.
Expand All @@ -23,6 +27,8 @@ internal class TestPluginDiscoverer
{
private IFileHelper fileHelper;

private static List<string> UnloadableFiles = new List<string>();

/// <summary>
/// Initializes a new instance of the <see cref="TestPluginDiscoverer"/> class.
/// </summary>
Expand Down Expand Up @@ -128,6 +134,10 @@ private void GetTestExtensionsFromFiles<TPluginInfo, TExtension>(
// Scan each of the files for data extensions.
foreach (var file in files)
{
if (UnloadableFiles.Contains(file))
{
continue;
}
try
{
Assembly assembly = null;
Expand All @@ -138,10 +148,16 @@ private void GetTestExtensionsFromFiles<TPluginInfo, TExtension>(
this.GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(assembly, pluginInfos);
}
}
catch (FileLoadException e)
{
EqtTrace.Warning("TestPluginDiscoverer-FileLoadException: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e);
string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file);
TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage);
UnloadableFiles.Add(file);
}
catch (Exception e)
{
EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e);
continue;
}
}
}
Expand All @@ -161,8 +177,8 @@ private void GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(Assembly ass
{
Debug.Assert(assembly != null, "null assembly");
Debug.Assert(pluginInfos != null, "null pluginInfos");

Type[] types;

try
{
types = assembly.GetTypes();
Expand All @@ -178,7 +194,6 @@ private void GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(Assembly ass
EqtTrace.Warning("LoaderExceptions: {0}", ex);
}
}

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IDiscoveryManager
/// Initializes the discovery manager.
/// </summary>
/// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
void Initialize(IEnumerable<string> pathToAdditionalExtensions);
void Initialize(IEnumerable<string> pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler);

/// <summary>
/// Discovers tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface IExecutionManager
/// Initializes the execution manager.
/// </summary>
/// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
void Initialize(IEnumerable<string> pathToAdditionalExtensions);
void Initialize(IEnumerable<string> pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler);

/// <summary>
/// Starts the test run with sources.
Expand Down
14 changes: 11 additions & 3 deletions src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
<data name="FailedToFindInstalledUnitTestExtensions" xml:space="preserve">
<value>Failed to find the list of installed unit test extensions. Reason: {0}</value>
</data>
<data name="FailedToLoadAdapaterFile" xml:space="preserve">
<value>Failed to load extensions from file '{0}'. Please use /diag for more information.</value>
</data>
<data name="FastFilterException" xml:space="preserve">
<value>An error occured while creating Fast filter.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Operace se ruší na základě žádosti.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Der Vorgang wird gemäß Anforderung abgebrochen.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">La operación se cancelará como se ha solicitado.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Annulation de l'opération, comme demandé.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">L'operazione verrà annullata come richiesto.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">操作のキャンセルが要求されたため、キャンセルしています。</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">요청한 대로 작업을 취소하는 중입니다.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Anulowanie operacji zgodnie z żądaniem.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Cancelando a operação conforme solicitado.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">Операция отменяется в соответствии с запросом.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">İşlem istek üzerine iptal ediliyor.</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@
<target state="new">Cancelling the operation as requested.</target>
<note></note>
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">按要求取消该操作。</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
<target state="translated">正在應要求取消作業。</target>
<note />
</trans-unit>
<trans-unit id="FailedToLoadAdapaterFile">
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit 33a2be6

Please sign in to comment.