Skip to content

Commit 33a2be6

Browse files
DineshChirnanchumayankbansal018
authored andcommitted
Adapter Failed to Load #958 (#2156)
* 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
1 parent 462d367 commit 33a2be6

32 files changed

+288
-40
lines changed

src/Microsoft.TestPlatform.Common/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class TestPlatformDefaults
1212
/// string in the vstest.console.exe.config that specifies the bound on no of jobs in the job queue.
1313
/// </summary>
1414
public const string MaxNumberOfEventsLoggerEventQueueCanHold = "MaxNumberOfEventsLoggerEventQueueCanHold";
15-
15+
1616
/// <summary>
1717
/// Default bound on the job queue.
1818
/// </summary>

src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework
77
using System.Collections.Generic;
88
using System.Diagnostics;
99
using System.Diagnostics.CodeAnalysis;
10+
using System.Globalization;
1011
using System.IO;
1112
using System.Linq;
1213
using System.Reflection;
13-
14+
using System.Xml;
1415
using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities;
16+
using Microsoft.VisualStudio.TestPlatform.Common.Logging;
1517
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
18+
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
1619
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
1720
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
21+
using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources.Resources;
1822

1923
/// <summary>
2024
/// Discovers test extensions in a directory.
@@ -23,6 +27,8 @@ internal class TestPluginDiscoverer
2327
{
2428
private IFileHelper fileHelper;
2529

30+
private static List<string> UnloadableFiles = new List<string>();
31+
2632
/// <summary>
2733
/// Initializes a new instance of the <see cref="TestPluginDiscoverer"/> class.
2834
/// </summary>
@@ -128,6 +134,10 @@ private void GetTestExtensionsFromFiles<TPluginInfo, TExtension>(
128134
// Scan each of the files for data extensions.
129135
foreach (var file in files)
130136
{
137+
if (UnloadableFiles.Contains(file))
138+
{
139+
continue;
140+
}
131141
try
132142
{
133143
Assembly assembly = null;
@@ -138,10 +148,16 @@ private void GetTestExtensionsFromFiles<TPluginInfo, TExtension>(
138148
this.GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(assembly, pluginInfos);
139149
}
140150
}
151+
catch (FileLoadException e)
152+
{
153+
EqtTrace.Warning("TestPluginDiscoverer-FileLoadException: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e);
154+
string fileLoadErrorMessage = string.Format(CultureInfo.CurrentUICulture, CommonResources.FailedToLoadAdapaterFile, file);
155+
TestSessionMessageLogger.Instance.SendMessage(TestMessageLevel.Warning, fileLoadErrorMessage);
156+
UnloadableFiles.Add(file);
157+
}
141158
catch (Exception e)
142159
{
143160
EqtTrace.Warning("TestPluginDiscoverer: Failed to load extensions from file '{0}'. Skipping test extension scan for this file. Error: {1}", file, e);
144-
continue;
145161
}
146162
}
147163
}
@@ -161,8 +177,8 @@ private void GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(Assembly ass
161177
{
162178
Debug.Assert(assembly != null, "null assembly");
163179
Debug.Assert(pluginInfos != null, "null pluginInfos");
164-
165180
Type[] types;
181+
166182
try
167183
{
168184
types = assembly.GetTypes();
@@ -178,7 +194,6 @@ private void GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(Assembly ass
178194
EqtTrace.Warning("LoaderExceptions: {0}", ex);
179195
}
180196
}
181-
182197
return;
183198
}
184199

src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IDiscoveryManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface IDiscoveryManager
1616
/// Initializes the discovery manager.
1717
/// </summary>
1818
/// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
19-
void Initialize(IEnumerable<string> pathToAdditionalExtensions);
19+
void Initialize(IEnumerable<string> pathToAdditionalExtensions, ITestDiscoveryEventsHandler2 eventHandler);
2020

2121
/// <summary>
2222
/// Discovers tests

src/Microsoft.TestPlatform.Common/Interfaces/Engine/TesthostProtocol/IExecutionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IExecutionManager
1818
/// Initializes the execution manager.
1919
/// </summary>
2020
/// <param name="pathToAdditionalExtensions"> The path to additional extensions. </param>
21-
void Initialize(IEnumerable<string> pathToAdditionalExtensions);
21+
void Initialize(IEnumerable<string> pathToAdditionalExtensions, ITestMessageEventHandler testMessageEventsHandler);
2222

2323
/// <summary>
2424
/// Starts the test run with sources.

src/Microsoft.TestPlatform.Common/Resources/Resources.Designer.cs

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.TestPlatform.Common/Resources/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@
153153
<data name="FailedToFindInstalledUnitTestExtensions" xml:space="preserve">
154154
<value>Failed to find the list of installed unit test extensions. Reason: {0}</value>
155155
</data>
156+
<data name="FailedToLoadAdapaterFile" xml:space="preserve">
157+
<value>Failed to load extensions from file '{0}'. Please use /diag for more information.</value>
158+
</data>
156159
<data name="FastFilterException" xml:space="preserve">
157160
<value>An error occured while creating Fast filter.</value>
158161
</data>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">Operace se ruší na základě žádosti.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">Der Vorgang wird gemäß Anforderung abgebrochen.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">La operación se cancelará como se ha solicitado.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">Annulation de l'opération, comme demandé.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">L'operazione verrà annullata come richiesto.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">操作のキャンセルが要求されたため、キャンセルしています。</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ko.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">요청한 대로 작업을 취소하는 중입니다.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pl.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">Anulowanie operacji zgodnie z żądaniem.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.pt-BR.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">Cancelando a operação conforme solicitado.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.ru.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">Операция отменяется в соответствии с запросом.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.tr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">İşlem istek üzerine iptal ediliyor.</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@
146146
<target state="new">Cancelling the operation as requested.</target>
147147
<note></note>
148148
</trans-unit>
149+
<trans-unit id="FailedToLoadAdapaterFile">
150+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
151+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
152+
<note></note>
153+
</trans-unit>
149154
</body>
150155
</file>
151156
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hans.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">按要求取消该操作。</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

src/Microsoft.TestPlatform.Common/Resources/xlf/Resources.zh-Hant.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@
269269
<target state="translated">正在應要求取消作業。</target>
270270
<note />
271271
</trans-unit>
272+
<trans-unit id="FailedToLoadAdapaterFile">
273+
<source>Failed to load extensions from file '{0}'. Please use /diag for more information.</source>
274+
<target state="new">TestPluginDiscoverer: Failed to load extensions from file '{0}'. Please use /diag for more information.</target>
275+
<note></note>
276+
</trans-unit>
272277
</body>
273278
</file>
274279
</xliff>

0 commit comments

Comments
 (0)