Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
321abc1
added the option
engyebrahim Aug 20, 2024
60294ef
added validation for the timeout
engyebrahim Aug 20, 2024
78987fd
added the logic but changed sort of test hot services(failing)
engyebrahim Aug 20, 2024
c731603
updated and fixed the logic
engyebrahim Aug 20, 2024
8510890
Merge branch 'main' into Enji/timeout
engyebrahim Aug 20, 2024
6d8854f
update the throw
engyebrahim Aug 20, 2024
2039cf8
update error message
engyebrahim Aug 20, 2024
64a2bde
Merge branch 'main' into Enji/timeout
engyebrahim Aug 20, 2024
c706714
Merge branch 'main' into Enji/timeout
Evangelink Aug 20, 2024
92d6f44
fix build
engyebrahim Aug 21, 2024
4013ec1
Merge branch 'Enji/timeout' of https://github.com/microsoft/testfx in…
engyebrahim Aug 21, 2024
186d979
Merge branch 'main' into Enji/timeout
engyebrahim Aug 21, 2024
6ca6701
add option description
engyebrahim Aug 21, 2024
39d9a1a
fixed some resrs
engyebrahim Aug 21, 2024
332320e
fixed all tests
engyebrahim Aug 21, 2024
966612a
Merge branch 'main' into Enji/timeout
engyebrahim Aug 21, 2024
c78ab81
added the invalid test cases
engyebrahim Aug 21, 2024
2cb84a8
Merge branch 'Enji/timeout' of https://github.com/microsoft/testfx in…
engyebrahim Aug 21, 2024
6980c90
Merge branch 'main' into Enji/timeout
engyebrahim Aug 21, 2024
566b963
added more tests
engyebrahim Aug 21, 2024
7e423e3
Merge branch 'Enji/timeout' of https://github.com/microsoft/testfx in…
engyebrahim Aug 21, 2024
48ff1df
added float value
engyebrahim Aug 21, 2024
9cbb250
Merge branch 'main' into Enji/timeout
engyebrahim Aug 21, 2024
114085e
Merge branch 'main' into Enji/timeout
engyebrahim Aug 21, 2024
4222421
update failing test
engyebrahim Aug 21, 2024
98771f8
update tests
engyebrahim Aug 21, 2024
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 @@ -15,6 +15,7 @@ internal sealed class PlatformCommandLineProvider : ICommandLineOptionsProvider
{
public const string HelpOptionKey = "help";
public const string HelpOptionQuestionMark = "?";
public const string TimeoutOptionKey = "timeout";
public const string InfoOptionKey = "info";
public const string DiagnosticOptionKey = "diagnostic";
public const string DiagnosticOutputFilePrefixOptionKey = "diagnostic-output-fileprefix";
Expand Down Expand Up @@ -46,6 +47,7 @@ internal sealed class PlatformCommandLineProvider : ICommandLineOptionsProvider
// Visible options
new(HelpOptionKey, PlatformResources.PlatformCommandLineHelpOptionDescription, ArgumentArity.Zero, false, isBuiltIn: true),
new(InfoOptionKey, PlatformResources.PlatformCommandLineInfoOptionDescription, ArgumentArity.Zero, false, isBuiltIn: true),
new(TimeoutOptionKey, PlatformResources.PlatformCommandLineTimeoutOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true),
new(ResultDirectoryOptionKey, PlatformResources.PlatformCommandLineResultDirectoryOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true),
new(DiagnosticOptionKey, PlatformResources.PlatformCommandLineDiagnosticOptionDescription, ArgumentArity.Zero, false, isBuiltIn: true),
new(DiagnosticOutputFilePrefixOptionKey, PlatformResources.PlatformCommandLineDiagnosticOutputFilePrefixOptionDescription, ArgumentArity.ExactlyOne, false, isBuiltIn: true),
Expand Down Expand Up @@ -113,6 +115,16 @@ public Task<ValidationResult> ValidateOptionArgumentsAsync(CommandLineOption com
return ValidationResult.InvalidTask(string.Format(CultureInfo.InvariantCulture, PlatformResources.PlatformCommandLineExitOnProcessExitSingleArgument, ExitOnProcessExitOptionKey));
}

if (commandOption.Name == TimeoutOptionKey)
{
string arg = arguments[0];
int size = arg.Length;
if ((char.ToLowerInvariant(arg[size - 1]) != 'h' && char.ToLowerInvariant(arg[size - 1]) != 'm' && char.ToLowerInvariant(arg[size - 1]) != 's') || !float.TryParse(arg[..(size - 1)], out float _))
{
return ValidationResult.InvalidTask(PlatformResources.PlatformCommandLineTimeoutArgumentErrorMessage);
}
}

// Now validate the minimum expected tests option
return IsMinimumExpectedTestsOptionValidAsync(commandOption, arguments);
}
Expand Down
24 changes: 23 additions & 1 deletion src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,30 @@ public async Task<ITestHost> BuildAsync(
Logging.AddProvider((_, _) => loggingState.FileLoggerProvider);
}

// Register the server mode log forwarder if needed. We follow the console --diagnostic behavior.
Comment thread
Evangelink marked this conversation as resolved.
Resolved
ICommandLineOptions commandLineOptions = serviceProvider.GetCommandLineOptions();

// setting the timeout
if (commandLineOptions.IsOptionSet(PlatformCommandLineProvider.TimeoutOptionKey) && commandLineOptions.TryGetOptionArgumentList(PlatformCommandLineProvider.TimeoutOptionKey, out string[]? args))
{
string arg = args[0];
int size = arg.Length;
if (!float.TryParse(arg[..(size - 1)], out float value))
{
throw ApplicationStateGuard.Unreachable();
}

TimeSpan timeout = char.ToLowerInvariant(arg[size - 1]) switch
{
'h' => TimeSpan.FromHours(value),
'm' => TimeSpan.FromMinutes(value),
's' => TimeSpan.FromSeconds(value),
_ => throw ApplicationStateGuard.Unreachable(),
};

testApplicationCancellationTokenSource.CancelAfter(timeout);
Comment thread
MarcoRossignoli marked this conversation as resolved.
Resolved
}

// Register the server mode log forwarder if needed. We follow the console --diagnostic behavior.
if (commandLineOptions.IsOptionSet(PlatformCommandLineProvider.ServerOptionKey) && loggingState.FileLoggerProvider is not null)
{
ServerLoggerForwarderProvider serverLoggerProxy = new(loggingState.LogLevel, serviceProvider);
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 @@ -602,4 +602,10 @@ Read more about Microsoft Testing Platform telemetry: https://aka.ms/testingplat
<data name="TerminalOutputOptionInvalidArgument" xml:space="preserve">
<value>--output expects a single parameter with value 'Normal' or 'Detailed'.</value>
</data>
<data name="PlatformCommandLineTimeoutArgumentErrorMessage" xml:space="preserve">
<value>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</value>
</data>
<data name="PlatformCommandLineTimeoutOptionDescription" xml:space="preserve">
<value>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">Případné PID nadřazeného hostitelského řadiče testů</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Most k rozhraním API VSTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">Die PID des letztlich übergeordneten Testhostcontrollers.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Brücke zu VSTest-APIs</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">PID del controlador de host de la posible prueba primaria.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Puente a las API de VSTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">PID du contrôleur hôte de test parent éventuel.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Pont vers les API VSTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">PID del controller host di test padre finale.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Esegui il bridge con le API VSTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,16 @@
<target state="translated">最終的な親テスト ホスト コントローラー PID。</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">VSTest API へのブリッジ</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">최종 부모 테스트 호스트 컨트롤러 PID입니다.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">VSTest API에 대한 브리지</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">Identyfikator PID ostatecznego nadrzędnego kontrolera hosta testów.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Mostek do interfejsów API narzędzia VSTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">PID do controlador de host de teste pai eventual.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Ponte para APIs vsTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">Итоговый идентификатор процесса контроллера узла родительского теста.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">Мост к API VSTest</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">Son üst test ana bilgisayar denetleyicisi PID'si.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">VSTest API'leri köprüsü</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,16 @@
<target state="translated">最终父测试主机控制器 PID。</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutArgumentErrorMessage">
<source>'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</source>
<target state="new">'timeout' option should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineTimeoutOptionDescription">
<source>A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</source>
<target state="new">A global test execution timeout, it should have one argument as string in the format &lt;value&gt;[h|m|s] where 'value' is float.</target>
<note />
</trans-unit>
<trans-unit id="PlatformCommandLineVSTestAdapterModeOptionDescription">
<source>Bridge to VSTest APIs</source>
<target state="translated">到 VSTest API 的桥</target>
Expand Down
Loading