don't report communication error on discovery abort (#14992)

* don't report communication error on discovery abort

* revert
This commit is contained in:
Jakub Jareš 2025-01-28 15:12:33 +01:00 коммит произвёл GitHub
Родитель 2b36dc5592
Коммит 06f4f131ae
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -196,20 +196,25 @@ public class ProxyDiscoveryManager : IProxyDiscoveryManager, IBaseProxy, ITestDi
private void HandleException(Exception exception)
{
EqtTrace.Error("ProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception);
// If requested abort and the code below was just sending data, we will get communication exception because we try to write the channel that is already closed.
// In such case don't report the exception because user cannot do anything about it.
if (!(_proxyOperationManager != null && _proxyOperationManager.CancellationTokenSource.IsCancellationRequested && exception is CommunicationException))
{
EqtTrace.Error("ProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception);
// Log to vs ide test output
var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = exception.ToString() };
var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload);
HandleRawMessage(rawMessage);
// Log to vs ide test output
var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = exception.ToString() };
var rawMessage = _dataSerializer.SerializePayload(MessageType.TestMessage, testMessagePayload);
HandleRawMessage(rawMessage);
// Log to vstest.console
HandleLogMessage(TestMessageLevel.Error, exception.ToString());
}
// Log to vstest.console
// Send a discovery complete to caller. Similar logic is also used in ParallelProxyDiscoveryManager.DiscoverTestsOnConcurrentManager
// Aborted is `true`: in case of parallel discovery (or non shared host), an aborted message ensures another discovery manager
// created to replace the current one. This will help if the current discovery manager is aborted due to irreparable error
// and the test host is lost as well.
HandleLogMessage(TestMessageLevel.Error, exception.ToString());
var discoveryCompletePayload = new DiscoveryCompletePayload
{
IsAborted = true,