Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Dec 4, 2024
1 parent 26964af commit 39971bd
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net.Sockets;

using Microsoft.Testing.Internal.Framework;
Expand Down Expand Up @@ -287,13 +288,14 @@ private async Task HandleNotificationAsync(NotificationMessage message, Cancella
Exception? cancellationException = rpcState.CancelRequest();
if (cancellationException is null)
{
// This is intentionally not using PlatformResources.ExceptionDuringCancellationWarningMessage
// It's meant for troubleshooting and shouldn't be localized.
// The localized message that is user-facing will be displayed in the DisplayAsync call next line.
await _logger.LogWarningAsync($"Exception during the cancellation of request id '{args.CancelRequestId}'");

// TODO: Localize
await ServiceProvider.GetOutputDevice().DisplayAsync(
this,
new WarningMessageOutputDeviceData(
$"Exception during the cancellation of request id '{args.CancelRequestId}'"));
new WarningMessageOutputDeviceData(string.Format(CultureInfo.InvariantCulture, PlatformResources.ExceptionDuringCancellationWarningMessage, args.CancelRequestId)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

namespace Microsoft.Testing.Platform.OutputDevice;

// Any interfaces that can have special treatment for any output device should be implemented by
// this proxy class and be forwarded properly.
// This is not so good. How can we make sure we are not missing any interfaces that may be implemented by external output devices?
internal sealed class ProxyOutputDevice : IOutputDevice
{
private readonly ServerModePerCallOutputDevice? _serverModeOutputDevice;
Expand Down Expand Up @@ -60,6 +57,14 @@ internal async Task DisplayAfterSessionEndRunAsync()

internal async Task InitializeAsync(ServerTestHost serverTestHost)
{
// Server mode output device is basically used to send messages to Test Explorer.
// For that, it needs the ServerTestHost.
// However, the ServerTestHost is available later than the time we create the output device.
// So, the server mode output device is initially created early without the ServerTestHost, and
// it keeps any messages in a list.
// Later when ServerTestHost is created and is available, we initialize the server mode output device.
// The initialization will setup the right state for pushing to Test Explorer, and will push any existing
// messages to Test Explorer as well.
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.InitializeAsync(serverTestHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace Microsoft.Testing.Platform.OutputDevice;
/// <summary>
/// Implementation of output device that writes to terminal with progress and optionally with ANSI.
/// </summary>
// NOTE: !!! Any interfaces here will likely need to be implemented by ProxyPlatformOutputDevice as well. !!!
internal partial class TerminalOutputDevice : IHotReloadPlatformOutputDevice,
IDataConsumer,
IOutputDeviceDataProducer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,8 @@ Takes one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is
<value>[ServerTestHost.OnTaskSchedulerUnobservedTaskException] Unhandled exception: {0}</value>
<comment>{0} is the exception that was unhandled/unobserved</comment>
</data>
<data name="ExceptionDuringCancellationWarningMessage" xml:space="preserve">
<value>Exception during the cancellation of request id '{0}'</value>
<comment>{0} is the request id</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Zprostředkovatel {0} (UID: {1}) selhal s chybou: {2}.</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Ukončovací kód</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Anbieter "{0}" (UID: {1}) ist mit folgendem Fehler fehlgeschlagen: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Exitcode</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Error del proveedor "{0}" (UID: {1}) con el error: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Código de salida</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Désolé, échec de l’« {0} » du fournisseur (UID : {1}) avec l’erreur : {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Code de sortie</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Provider '{0}' (UID: {1}) non riuscito con errore: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Codice di uscita</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">プロバイダー '{0}' (UID: {1}) が次のエラーで失敗しました: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">終了コード</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">공급자 '{0}'(UID: {1})이 오류 {2}(으)로 실패했습니다.</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">종료 코드</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Dostawca „{0}” (UID:{1}) nie powiódł się z powodu błędu: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Kod zakończenia</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">O provedor ''{0}'' (UID: {1}) falhou com o erro: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Código de saída</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">Сбой поставщика "{0}" (ИД пользователя: {1}) с ошибкой: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Код завершения</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">'{0}' sağlayıcısı '' (UID: {1}) şu hatayla başarısız oldu: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">Çıkış kodu</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">提供程序 '{0}' (UID: {1}) 失败,出现错误: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">退出代码</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<target state="translated">提供者 '{0}' (UID: {1}) 失敗,發生錯誤: {2}</target>
<note />
</trans-unit>
<trans-unit id="ExceptionDuringCancellationWarningMessage">
<source>Exception during the cancellation of request id '{0}'</source>
<target state="new">Exception during the cancellation of request id '{0}'</target>
<note>{0} is the request id</note>
</trans-unit>
<trans-unit id="ExitCode">
<source>Exit code</source>
<target state="translated">結束代碼</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --retry-failed-tests 3</TestRunnerAdditionalArguments>
<UseVSTestRunner>false</UseVSTestRunner>
<DefineConstants Condition=" '$(FastAcceptanceTest)' == 'true'">$(DefineConstants);SKIP_INTERMEDIATE_TARGET_FRAMEWORKS</DefineConstants>
<DefineConstants>$(DefineConstants);IS_MTP</DefineConstants>
<OutputType>Exe</OutputType>
<UseAppHost>true</UseAppHost>
</PropertyGroup>
Expand All @@ -15,7 +14,7 @@
<PackageReference Include="StreamJsonRpc" />
<PackageReference Include="Microsoft.Testing.Extensions.Retry" />

<Compile Include="$(RepoRoot)test\IntegrationTests\MSTest.Acceptance.IntegrationTests\ServerMode\**\*.cs" Link="%(RecursiveDir)%(FileName)%(Extension)" />
<Compile Include="$(RepoRoot)test\IntegrationTests\MSTest.Acceptance.IntegrationTests\ServerMode\**\*.cs" Link="ServerMode\%(RecursiveDir)%(FileName)%(Extension)" />
</ItemGroup>

<!-- Packages needed for the test assets but that we don't want to reference -->
Expand Down

0 comments on commit 39971bd

Please sign in to comment.